In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Old guys who often use linux and mac systems are used to using commands. If you want to use an operating system flexibly, you must be familiar with the commands inside. Not all of them can be interfaced. Let's familiarize ourselves with docker's commands.
Command collection management command: container management container image management mirror network management network node management Swarm node plugin management plug-in secret management Docker secrets service management service stack management Docker stacks swarm management Swarm cluster system view system information volume management volume such as: docker container ls shows that all containers are normal Command: attach enters a running container build from a DockerFile build image commit from the container creates an image cp copies files between the container and the host file system create creates a container diff checks changes on the container file system events gets real-time events from the server exec is running Run the command export in the container to export the container's file system to tar archive history display image history images view image list import create image info display system-wide information inspect returns low-level information of Docker object kill kill running container load from archive or STDIN plus Load image login login docker image repository logout exit docker image repository logs get the log of a container pause pause all processes in one or more containers port view port mapping or container specific mapping list ps view container list pull pull image push from image warehouse upload local image to image warehouse To log in to the image repository rename rename container restart restart container rm delete container rmi delete image run create a new container and run a command save saves the specified image as a tar archive file search searches for images from Docker Hub start starts container stats real-time display container Statistics of resource usage stop stop container tag tag local mirror Put it into a warehouse top display process running in a container unpause restore all processes in the container update update container configuration version display Docker version information wait blocking until the container stops, and then print exit code such as: docker images shows all images
Let the container run for a long time
Docker run-d centos / bin/bash-c "while true; do sleep 1 done"
Enter the container to check the operation of the container
Docker attach Container ID
Enter the inside of the container
Docker exec-it container ID / bin/bash
The main differences between attach and exec are as follows
1.attach goes directly to the terminal of the container startup command and does not start a new thread.
2.exec opens a new terminal in the container and can start a new thread.
3. If you want to view the output of the startup command directly in the terminal, use attach; in other cases and use exec.
Container operation
If the docker client runs using the docker command, the run parameter table name client will run a new client
> 1. Which image is the container created from? here is centos, the basic centos image.
> 2. The command to be run in the container, in this case / bin/bash, runs Bash shell in the container.
Docker run-it centos / bin/bash
So what happens at the bottom after running the above command?
In order, docker does these things:
1. Pull centos image: docker checks whether the centos image exists. If there is no local image, docker will be downloaded in docker hub. If the image already exists, docker will use it to create a new container.
two。 Create a new container: when docker has this image, docker will use it to create a container.
3. Allocate the file system and mount a read-write layer: the container is created in the file system, and a read-write layer is added to the image.
4. Assign a network / bridge interface: create a network interface that allows the container to communicate with the local host.
5. Set an IP address: find an available IP address from the pool and attach it to the container.
6. Run your designated program: run the specified program
7. Capture and provide application output: connect and record standard output, input and errors so that you can see how your program works.
End of batch deletion of containers
# an error was reported because there is currently no exit container. Docker rm-v $(docker ps-aq-f statue=exited)
Start, stop, restart, delete docker containers
# start Container docker start # stop Container docker stop # restart Container docker restart # Delete Container docker rm # Delete all containers docker rm $(docker ps-a-Q)
More detailed explanation of docker commands in actual combat
> it is recommended to read my articles on docker [Elementary] and [Intermediate]
The basic commands of PS:docker are very important, but if you can use help, the official introduction is clearer, I have also translated English here. The main thing is to understand the principle.
The original article is welcome to reprint. Reprint please indicate: reproduced from IT Story Association, thank you!
> > original link address: "docker practice" docker-docker system Management of python-basic commands (29)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.