1) installer docker
$ sudo apt-get remove docker docker-engine docker.io
$ sudo apt-get update
$ sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt-get update
1.1)
如果在 production 系統上安裝 docker 最好選擇固定版本,不然就直接用 latest
(optional but recommanded)
$ apt-cache madison docker-ce
docker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.2~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.2~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
$ sudo apt-get install docker-ce=17.09.0~ce-0~ubuntu
1.2)直接安裝 latest
(fast in dev environment)
$ sudo apt-get install -y docker-ce
1.3)post installation
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
1.4)重新登入測試能不能不用 sudo 執行 docker
$ docker run hello-world
$ sudo systemctl enable docker
1.5)若要移除
$ sudo apt-get purge docker-ce
$ sudo rm -rf /var/lib/docker
2.裝 nvidia-docker
2.1)官方教學在 nvidia-docker github 的 README.md 上
# Install nvidia-docker and nvidia-docker-plugin
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
2.2)這邊裝完有個 issue,所以要再加兩行
$ sudo service nvidia-docker start
$ sudo nvidia-docker-plugin
2.3)由於我是用 cuda8 ,所以在 docker 內測試 nvidia-smi 要用下列指令
$ nvidia-docker run --rm nvidia/cuda:8.0 nvidia-smi
2.4)應該會跟在 host machine 上直接 $ nvidia-smi
得到一樣的結果