Because things do not often contact with the operation and maintenance of the environment and just know to use, so do a docker command line cheat sheet record what everyday commonly used functions, programmers say that we rely on Baidu programming, I rely on CSDN cheat sheet.
Article Directory
1. Save docker container and restart
Operation and maintenance of the students to help configure a docker's image, but when docker mirror that is not what I want to mount the directory, this time I need a meal operations to meet my requirements.
- We need to save the image to view the
CONTAINER ID
sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c774d7a39fc registry.cn-hangzhou.aliyuncs.com/xdl/xdl:ubuntu-gpu-mxnet1.3 “/bin/bash” 4 weeks ago Up 4 weeks tdm-mock
According to the results obtained above to view the command CONTAINER ID
is4c774d7a39fc
- Use
docker commit
saved information Mirror
sudo docker commit 4c774d7a39fc hdfs-client-tdm
- Use
docker images
to view mirror information
sudo docker images | grep tdm
The results are as follows
hdfs-client-tdm latest b7705c08df80 2 minutes ago 10.2 GB
- Restart and mount the directory I want
sudo docker run -d --name tdm-client -it -v /path hdfs-client-tdm /bin/bash
docker run相关参数
-d:表示在后台运行
--name:表示执行的镜像的名称
--name:表示运行镜像生成的容器的名称
`-V: represents the path mount
- View the results after start
sudo docker ps -a
Finally generated are shown below
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b0c533bd16db hdfs-client-tdm “/bin/bash” 53 minutes ago Up 53 minutes tdm-client
2. Go to a container
Run command
sudo docker exec -it tdm-client /bin/bash