# Try to remove nvidia-docker 1.0
# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
# docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
# sudo apt-get purge -y nvidia-docker

# Try to remove docker docker-engine docker.io
# sudo apt-get remove docker docker-engine docker.io

# Install docker-ce
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
sudo apt-key add gpg
sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
      $(lsb_release -cs) \
         stable"
sudo apt-get update
# 查找Docker-CE的版本:
# sudo apt-cache madison docker-ce
#sudo apt-get -y install docker-ce=18.06.2~ce~3-0~ubuntu
sudo apt-get -y install docker-ce

# Install nvidia-docker
# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2

# configure docker images source
sudo cp daemon.json /etc/docker/daemon.json
sudo mkdir -p /etc/docker/certs.d/docker.dg-atlas.com:5000
sudo cp ca.crt /etc/docker/certs.d/docker.dg-atlas.com:5000/ca.crt
sudo service docker restart
