Brief introduction
Emmmm
Docker container management
Recommended Reading: container Technical Overview
run inside the sub-options
1. Create a container using the run command
docker container run -it ubuntu /bin/bash //docker container run -itd --name xiaohua centos
- -i : interactive operation.
- -t : terminal.
- Ubuntu : Ubuntu镜像.
- / bin / bash : after the command name on the mirror, where we hope to have an interactive Shell, therefore use the / bin / bash.
2. Use the PS command to view a list of container
docker container ps -a
3. Use the start command to start a container
docker container start hello
4. Use the restart command to restart the container
docker container restart hello
5. attach command connector receptacle
Container xiaohua the attach Docker // Format: docker attach <container name> connected to a container named xiaohua
Ctrl + D exit or enter the Bash shell terminates in a container. If the order input ctrl + P ctrl + Q to exit the container will not be terminated
6. exec command operation command from the external container
docker container exec xiaohua echo "hello" //docker exec<容器名称><命令><形式参数> //运行容器内的echo命令 //docker container exec -it xiaohua bash 分配的伪终端
7.使用stop终止容器
docker container stop xiaohua //docker stop <容器名称> 也可以使用容器ID替代名称
8.使用rm命令删除容器
docker container rm xiaohua //docker rm <容器名称> 也可以使用容器ID替代名称
9.查看容器的详细信息(记录Docker容器配置状态信息)
docker container inspect xiaohua
10.使用top查看容器内部运行的进程
docker container top xiaohua
11.查看容器日志
docker container logs xiaohua
12.查看容器资源
docker container stats xiaohua