Easy way to use docker on your Ubuntu system
My computer env.
Ubuntu 16.04 LTS, Nvidia GTX 1080ti
Note
The latest graphic driver should be installed in advance
1. install docker
(https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce-1)
a. list the version
$ sudo apt-cache madison docker-ce
b. install specific version
$ sudo apt-get install docker-ce=18.03.1~ce-0-ubuntu
If nothing works, follows
https://unix.stackexchange.com/questions/363048/unable-to-locate-package-docker-ce-on-a-64bit-ubuntu
2. install nvidia-docker (the latest graphic driver should be installed in advance)
(http://www.kwangsiklee.com/ko/2018/02/%EC%A0%95%EB%A6%AC-ubuntu%EC%84%9C%EB%B2%84%EC%97%90-nvidia-docker-%EC%84%A4%EC%B9%98-%ED%95%98%EA%B8%B0/)
a. add repository
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
sudo apt-key add -
$ curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list
$ sudo apt-get update
b. install package
$ sudo apt-get install -y nvidia-docker2
c. shut down
$ sudo pkill -SIGHUP dockerd
3. download and run tensorflow latest docker (gpu version)
.this command will download the latest tensorflow with all required packages
.after the download, a contrainer will be running
a) download and run
$ nvidia-docker run -it -p 8888:8888 tensorflow/tensorflow:latest-devel-gpu
b) check
$python
$import tensorflow as tf
$print(tf.__version__)
c) exit
4. create a contrainer
a) check image name
$ nvidia-docker images
b) create a container
$ nvidia-docker run -it -d -p 8888:8888 --name container_name -v /home/dooseop/tmp:/tmp image_name
c) excecute container
$ nvidia-docker exec -it container_name /bin/bash