table of Contents
1. Get the mirror image/pull or update the specified mirror image from the mirror warehouse
2. Create a container based on the image
3. Start the stopped container
1. Get the mirror image/pull or update the specified mirror image from the mirror warehouse
docker pull: pull or update the specified mirror from the mirror warehouse, for example
docker pull paddlepaddle/paddle:2.0.1-gpu-cuda11.0-cudnn8
2. Create a container based on the image
docker run: Create a new container and run a command, for example
sudo nvidia-docker run --name ppocr -v $PWD:/paddle --shm-size=252G --network=host -itd paddlepaddle/paddle:2.0.1-gpu-cuda11.0-cudnn8 /bin/bash
--name: Specify the name of the container.
-v: v refers to volume, which means to map the current directory to the /paddle path in the container,
-d: Run the container in the background and return the container ID;
-i: Run the container in interactive mode, usually used together with -t;
-t: reassign a pseudo input terminal for the container, usually used at the same time as -i;
--shm-size=256G: Here is to set the shared memory size in the docker environment. The default is 64m, which is too small, and an error will be reported when the program is run later, so use the df-h command on the computer to look at the computer before creating the container The virtual memory size is set to the same when the docker container is created. The following /dev/shm is the shared memory size.
root@boyun-DGX-1-with-V100-32:/data/chw# df -h
Filesystem Size Used Avail Use% Mounted on
udev 252G 0 252G 0% /dev
tmpfs 51G 2.7M 51G 1% /run
/dev/sda2 3.5T 1.5T 1.9T 44% /
tmpfs 252G 0 252G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 252G 0 252G 0% /sys/fs/cgroup
3. Start the stopped container
sudo docker start <容器ID>
For example, let's first use sudo docker ps to see which containers are there
chw@chw-System-Product-Name:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb2feff5b9de hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev "/bin/bash" 3 hours ago Exited (0) 2 hours ago ppocr
20b076254ee8 hello-world "/hello" 3 hours ago Exited (0) 3 hours ago busy_neumann
Then we can start a container based on the container ID, and then we can use sudo docker ps to see the currently running container, for example
chw@chw-System-Product-Name:~$ sudo docker start fb2feff5b9de
fb2feff5b9de
chw@chw-System-Product-Name:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb2feff5b9de hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev "/bin/bash" 3 hours ago Up 18 seconds ppocr
chw@chw-System-Product-Name:~$
4. Enter a container
docker exec -it <container ID> /bin/bash enters a certain container, for example, we used sudo docker start to start a certain container, and enter this container below,
chw@chw-System-Product-Name:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb2feff5b9de hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev "/bin/bash" 3 hours ago Exited (0) 2 hours ago ppocr
20b076254ee8 hello-world "/hello" 3 hours ago Exited (0) 3 hours ago busy_neumann
chw@chw-System-Product-Name:~$ sudo docker start fb2feff5b9de
fb2feff5b9de
chw@chw-System-Product-Name:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb2feff5b9de hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev "/bin/bash" 3 hours ago Up 18 seconds ppocr
chw@chw-System-Product-Name:~$ sudo docker exec -it fb2feff5b9de /bin/bash
λ chw-System-Product-Name /home
5. Exit a container
Direct ctrl+D or enter exit
chw@chw-System-Product-Name:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb2feff5b9de hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev "/bin/bash" 3 hours ago Exited (0) 2 hours ago ppocr
20b076254ee8 hello-world "/hello" 3 hours ago Exited (0) 3 hours ago busy_neumann
chw@chw-System-Product-Name:~$ sudo docker start fb2feff5b9de
fb2feff5b9de
chw@chw-System-Product-Name:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb2feff5b9de hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev "/bin/bash" 3 hours ago Up 18 seconds ppocr
chw@chw-System-Product-Name:~$ sudo docker exec -it fb2feff5b9de /bin/bash
λ chw-System-Product-Name /home exit
chw@chw-System-Product-Name:~$
6. Stop a container
sudo docker stop <容器ID>
chw@chw-System-Product-Name:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb2feff5b9de hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev "/bin/bash" 3 hours ago Up 7 minutes ppocr
chw@chw-System-Product-Name:~$ sudo docker stop fb2feff5b9de
fb2feff5b9de
chw@chw-System-Product-Name:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7. Delete the container
To delete the container, use the docker rm command: sudo docker rm -f <container ID>
chw@chw-System-Product-Name:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb2feff5b9de hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev "/bin/bash" 3 hours ago Exited (0) About a minute ago ppocr
20b076254ee8 hello-world "/hello" 3 hours ago Exited (0) 3 hours ago busy_neumann
chw@chw-System-Product-Name:~$ sudo docker rm -f fb2feff5b9de
fb2feff5b9de
chw@chw-System-Product-Name:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
20b076254ee8 hello-world "/hello" 3 hours ago Exited (0) 3 hours ago busy_neumann
chw@chw-System-Product-Name:~$
8. List the mirror list
docker images : List the images on the local host
chw@chw-System-Product-Name:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d1165f221234 2 weeks ago 13.3kB
hub.baidubce.com/paddlepaddle/paddle latest-gpu-cuda9.0-cudnn7-dev b6437d2ae45e 7 months ago 8.73GB
9. Delete the mirror
To delete the image, use the docker rmi command, for example
chw@chw-System-Product-Name:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d1165f221234 2 weeks ago 13.3kB
hub.baidubce.com/paddlepaddle/paddle latest-gpu-cuda9.0-cudnn7-dev b6437d2ae45e 7 months ago 8.73GB
chw@chw-System-Product-Name:~$
chw@chw-System-Product-Name:~$
chw@chw-System-Product-Name:~$
chw@chw-System-Product-Name:~$ sudo docker rmi b6437d2ae45e
Untagged: hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev
Untagged: hub.baidubce.com/paddlepaddle/paddle@sha256:49a12aa8179c83443f66bafcff417edb174d1937fd5ef29f63122a3e70f7098a
Deleted: sha256:b6437d2ae45e3a9afca9996c3de9391b55ee5da2634d9b8c27f784ca9dc1274b
.......
Deleted: sha256:7082d7d696f8489bc9030e119acc56e210b6314bc8ac91aa69ed11c57c9243ba
chw@chw-System-Product-Name:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d1165f221234 2 weeks ago 13.3kB
chw@chw-System-Product-Name:~$