In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what are the basic operations of image container in Docker". In the daily operation, I believe many people have doubts about the basic operation of image container in Docker. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the basic operations of image container in Docker?" Next, please follow the editor to study!
Basic concepts of image container basic operations:
Container
The container. You can think of each container as a separate host. The creation of a container usually has an image as its template. Analogy to virtual machines can be understood as image is the mirror image of virtual machines, while container is a running virtual machine. A virtual machine image can create multiple running virtual hosts that are independent of each other. Note: once container is created, it will always exist if it is not removed with the rm command. So remember to delete it after you use it.
Image
Mirror image. Image is equivalent to a template for container, and what software is in it after container is created depends entirely on what image it uses. Image can be created through container (equivalent to saving the state of container as a snapshot at this time) or through Dockerfile (a text file that uses some of the writing specified by docker). The method created by Dockerfile allows the environment configuration and code to be managed by the version library together.
Registry
The warehouse where the images are stored. As long as you can connect to the registry, everyone can easily get the image from the repository through the pull command. The default repository used by docker is docker hub. In China, you can use DaoCloud to establish a connection between Mirror and docker hub, thus speeding up the acquisition of image.
Boot2docker
A lightweight linux virtual machine, mainly to make non-linux systems can also use docker. It is essentially a virtualbox virtual host + a command line tool that can manage the virtual host. Because of the existence of this virtual host, when container needs to obtain some physical system resources (such as usb devices) on non-linux systems, it needs not only to configure the docker command, but also to configure the resource configuration of boot2docker as a virtual host.
Common command list
General:
Operation command sample view docker version docker versiondocker version view docker information docker infodocker info view a command help information docker help [command] docker help attach view docker help information docker-- helpdocker-- help
Container related:
Operation command example create containerdocker createdocker create chenhengjie123/xwalkdriver create and run containerdocker rundocker run chenhengjie123/xwalkdriver / bin/bash create and run container enter its bash console docker run-t-I image / bin/bashdocker run-t-I ubuntu / bin/bash create and run container and let it run in the background And port mapping docker run-p [port in container]: [port in physical system]-d [image] [command] docker run-p 5000image 5000-d training/webapp python app.py view all running container information docker psdocker ps view last created containerdocker ps-ldocker ps-l view all container, including running and closed docker ps-adocker ps-an outputs the stdout information of the specified container (used to see log, the effect is similar to tail-f, and will be output in real time. ) docker logs-f [container] docker logs-f nostalgic_morse get container designated port mapping relationship docker port [container] [port] docker port nostalgic_morse 5000 View container process list docker top [container] docker top nostalgic_morse View container details docker inspect [container] docker inspect nostalgic_morse stop continerdocker stop [container] docker stop nostalgic_morse stop containerdocker kill [container] docker kill nostalgic_morse start a stopped containerdocker start [container] docker start nostalgic_morse Restart container (if container is off Then directly launch) docker restart [container] docker restart nostalgic_morse to delete containerdocker rm [container] docker rm nostalgic_morse
When you need to specify container in the command, you can use either its name or its id.
Image related:
Example create imagedocker commit [container] [imageName] docker commit nostalgic_morse ouruser/sinatra:v2 from container create imagedocker build-t [imageName] [pathToFolder] docker build ouruser/sinatra:v3 from Dockerfile. View all local imagedocker imagesdocker images search for image in registry docker search [query] docker search ubuntu get image from registry (if no tag name is specified Then latest this tag) docker pull [imageName] docker pull ubuntu:14.04 is used by default. Docker pull training/webapp calls image tagdocker tag [imageId] [imageName] docker tag 5db5f8471261 ouruser/sinatra:devel to upload the local image to registry (all tag will be uploaded at this time) docker push [imageName] docker push ouruser/sinatra to delete the local imagedocker rmi [image] docker rmi training/sinatra.
Note: if the tag name is not specified in image, the tag latest is used by default. However, the meaning of latest is different from that of head in VCS. It does not represent the latest image, but only the image whose tag name is latest. An error will be reported if there is no mirror with the name latest of tag.
At this point, the study on "what are the basic operations of image container in Docker" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.