Try   HackMD

Docker Installation

tags: docker

https://linuxconfig.org/how-to-install-docker-on-ubuntu-18-04-bionic-beaver

sudo apt-get remove docker docker-engine docker.io curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial edge" | sudo tee /etc/apt/sources.list.d/docker.list sudo apt update sudo apt-get install docker-ce=18.06.1~ce~3-0~ubuntu 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 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 apt-cache madison nvidia-docker2 nvidia-container-runtime sudo apt-get install -y nvidia-docker2=2.0.3+docker18.06.1-1 nvidia-container-runtime=2.0.0+docker18.06.1-1 sudo docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0 --net=host -it nvidia/cuda:8.0-devel sudo docker run --gpus all -e NVIDIA_VISIBLE_DEVICES=0 --net=host -it nvidia/cuda:10.0-devel # downloading image

https://medium.com/@maniac.tw/ubuntu-18-04-安裝-nvidia-driver-418-cuda-10-tensorflow-1-13-a4f1c71dd8e5

adduser ierosodin apt update apt install byobu sudo vim adduser ierosodin sudo su ierosodin cp /etc/skel/.profile ~/.bash_profile cp /etc/skel/.bashrc ~/.bashrc sudo apt install ssh openssh-server # change port to 7015 sudo vim /etc/ssh/sshd_config

commit image before exit (in another terminal):

sudo docker ps -a sudo docker commit -m "v1" NAMES nvidia/cuda:8.0-devel

exit

vim docker_home/entry.sh

keyin:

#!/bin/bash sudo /etc/init.d/ssh start

login again:

sudo docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0 -e DISPLAY=$DISPLAY --net=host -it -v /home/ierosodin/docker_home:/home/ierosodin -v /mnt/hdd/shared_folder/ierosodin:/home/ierosodin/hdd -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 --shm-size 32G -v /dev:/dev --cap-add=ALL -u ierosodin -w=/home/ierosodin nvidia/cuda:8.0-devel
sudo docker run --gpus all -e NVIDIA_VISIBLE_DEVICES=0 --net=host -it -v /home/ierosodin/hdd/back_18/docker_home:/home/ierosodin -v /mnt/hdd/shared_folder/ierosodin:/home/ierosodin/hdd -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 --shm-size 32G -v /dev:/dev --cap-add=ALL -u ierosodin -w=/home/ierosodin nvidia/cuda:10.0-devel

change entry permission:

chmod +x entry.sh

commit then exit, now, it complete to set up environment.

sudo docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0 -e DISPLAY=$DISPLAY --net=host -it -v /home/ierosodin/docker_home:/home/ierosodin -v /mnt/hdd/shared_folder/ierosodin:/home/ierosodin/hdd -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 --shm-size 32G -v /dev:/dev --cap-add=ALL -u ierosodin -w=/home/ierosodin nvidia/cuda:8.0-devel /bin/bash -c "./entry.sh && byobu"

kill docker image which is exited

sudo docker rm $(sudo docker ps -a -q -f status=exited)

show all image which is used

sudo docker ps -a

kill image

sudo docker kill image id
sudo docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0,1 -e DISPLAY=$DISPLAY --net=host -it -v /home/robotics/docker_home:/home/robotics -v /mnt/hdd/shared_folder/robotics:/home/robotics/hdd -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 --shm-size 32G -v /dev:/dev --cap-add=ALL -u robotics -w=/home/robotics nvidia/cuda /bin/bash -c "./entry.sh && byobu" sudo docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=0,1 -e DISPLAY=$DISPLAY --net=host -it -v /home/robotics/docker_home:/home/robotics -v /mnt/hdd/shared_folder/robotics:/home/robotics/hdd -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 --shm-size 32G -v /dev:/dev --cap-add=ALL -u robotics -w=/home/robotics robotics_container /bin/bash -c "./entry.sh && sudo -H byobu"
  • 140.113.216.17
    • 7015 host
    • 8015 docker robotics
  • 140.113.216.18
    • 22 host
    • 7015 docker robotics
  • 28
    • 7015 docker ?

sudo docker run net=host -it -v /home/gapcmgr/upload/Tony:/home/ierosodin -u ierosodin -w=/home/ierosodin ubuntu:late
st /bin/bash -c "./entry.sh && byobu"

  • Build Dockerfile
    • go to the image context folder
    • command: docker build -t repo:tag -f [Dockerfile path]
  • Tag
    • docker tag source destination
  • Insecure registry
    • Add /etc/docker/daemon.json
      ​​​​​​​​​   {
      ​​​​​​​​​     "insecure-registries" : ["140.113.24.75"]
      ​​​​​​​​​   }
      

sudo docker run gpus all -e NVIDIA_VISIBLE_DEVICES=0 net=host -it -v /home/ierosodin/hdd/back_18/docker_home:/home/ierosodin -v /mnt/hdd/shared_folder/ierosodin:/home/ierosodin/hdd -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 shm-size 32G -v /dev:/dev cap-add=ALL -u ierosodin -w=/home/ierosodin nvidia/cuda:10.0-devel /bin/bash -c "./entry.sh && byobu"