Run docker and mount
$ nvidia-docker run --rm -it -v `pwd`:`pwd` -w `pwd` xxx/ubuntu:latest /bin/bash
Remove image
$ docker rmi ubuntu:latest
Remove container
$ docker rm CONTAINER_ID
Save container -> image
$ docker commit CONTAINER_ID ubuntu:latest2
Save image -> image
$ docker tag IMAGE_ID ubuntu:latest2
When CPU,
$ docker run --rm -it -v `pwd`:`pwd` -w `pwd` --net host -e DISPLAY=$DISPLAY -v $HOME/.Xauthority:/root/.Xauthority ubuntu:latest /bin/bash
When GPU,
$ nvidia-docker run --rm -it -v `pwd`:`pwd` -w `pwd` --net host -e DISPLAY=$DISPLAY -v $HOME/.Xauthority:/rot/.Xauthority ubuntu:latest /bin/bash
--- i ... Connect the standard input of the container and the input of the host --- t ... Connect the standard output of the container and the output of the host --- rm ... Erase when the container is closed --- v [Absolute host path]: [Absolute container path] ... Mount --- w [absolute path] ... Directory to run on the container ---- net host ... Use the network stack of the host on the container (?) --- e ... Set environment variables ---- net host -e DISPLAY = $ DISPLAY -v $ HOME / .Xauthority: /root/.Xauthority ... Magic for using GUI in container
$ brew cask install xquartz
Add the following to bash_profile
export DISPLAY_MAC=`ifconfig en0 | grep "inet " | cut -d " " -f2`:0
defaults write org.macosforge.xquartz.X11 nolisten_tcp -boolean false
function startx() {
if [ -z "$(ps -ef|grep XQuartz|grep -v grep)" ] ; then
open -a XQuartz
fi
}
This command when starting the container. Pay attention to DISPLAY.
$ docker container run -it -e DISPLAY=${DISPLAY_MAC} ubuntu:18.04
$ docker commit [CONTAINER_ID] [New_Repository]:[New_Tag]
$ docker tag [IMAGE_ID] [New_Repository]:[New_Tag]
Ctl + p in the terminal and ctl + q
$ docker attach [Container_ID]
$ docker rm [Container_ID]
Remove all contatiner,
$ docker rm $(docker ps -a -q)
$ docker rmi [Repository]:[Tag]
or
$ docker rmi [Image_ID]
$ docker rmi -f [Repository]:[Tag]
$ docker images
$ docker images -a
$ docker ps -a
$ docker login
$ docker push [DockerHub's_username]/[Repository]:[Tag]
$ docker logout
$ cat /etc/group | grep docker
$ sudo usermod -aG docker [User_Name]
$ docker pull ubuntu
$ docker pull nvidia/cuda
$ docker pull nvidia/cuda:8.0-devel
$ docker build -t [Repository]:[Tag] -f [Dockerfile_path] ./
Recommended Posts