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)06/01 Report--
This article mainly introduces "what commands are commonly used in Docker". In daily operation, I believe many people have doubts about what commands are commonly used 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 for you to answer the doubts about "what commonly used commands are there in Docker?" Next, please follow the editor to study!
Detailed arrangement of common commands in Docker
View Docker information (version, info)
# View docker version $docker version# display docker system information $docker info
Operations on image (search, pull, images, rmi, history)
# search image$docker search image_name# download image$docker pull image_name# to list images;-a,-- all=false Show all images;-- no-trunc=false Don't truncate output;-Q,-- quiet=false Only show numeric IDs$docker images# delete one or more images;-f,-- force=false Force;-- no-prune=false Do not delete untagged parents$docker rmi image_name# displays the history of a mirror;-- no-trunc=false Don't truncate output -Q,-- quiet=false Only show numeric IDs$docker history image_name
Launch Container (run)
The docker container can be understood as a process running in sandboxie. This sandboxie contains the resources necessary for the process to run, including the file system, system class library, shell environment, and so on. But this sandboxie will not run any programs by default. You need to run a process in sandboxie to start a container. This process is the only process in the container, so when the process ends, the container stops completely.
# run the "echo" command in the container and output "hello word" $docker run image_name echo "hello word" # enter the container interactively $docker run-I-t image_name / bin/bash# install a new program in the container $docker run image_name apt-get install-y app_name
Note: take the-y parameter with you when you execute the apt-get command. If the-y parameter is not specified, the apt-get command enters interactive mode and requires the user to enter a command for confirmation, but there is no way to respond to this interaction in the docker environment. After the apt-get command is executed, the container stops, but the changes to the container are not lost.
View the container (ps)
# list all currently running container$docker ps# list all container$docker ps-a # list the most recently launched container$docker ps-l
Save changes to the container (commit)
When you make changes to a container (by running a command in the container), you can save the changes to the container so that next time you can run the container from the latest state after saving.
# Save changes to the container;-a,-- author= "" Author;-m,-- message= "" Commit message$docker commit ID new_image_name
Note: image is the equivalent of a class, and Container is the equivalent of an instance, but you can dynamically install new software for the instance, and then solidify the container into an image with the commit command.
Operations on containers (rm, stop, start, kill, logs, diff, top, cp, restart, attach)
# delete all containers $docker rm `container-a-q` # Delete a single container;-f,-- force=false;-l,-- link=false Remove the specified link and not the underlying container;-v,-- volumes=false Remove the volumes associated to the container$docker rm Name/ID# stop, start, kill a container $docker stop Name/ID$docker start Name/ID$docker kill Name/ID# to take logs from a container;-f,-- follow=false Follow log output -t,-- timestamps=false Show timestamps$docker logs Name/ID# lists the files or directories that have been changed in a container, and the list list shows three events, An added and D deleted C changed $docker diff Name/ID# displays process information in a running container $docker top Name/ID# copies files / directories from the container to a local path $docker cp Name:/container_path to_path$docker cp ID:/container_path to_path# restarts a running container -t,-- time=10 Number of seconds to try to stop for before killing the container, Default=10$ docker restart Name/ID# is attached to a running container;-- no-stdin=false Do not attach stdin;-- sig-proxy=true Proxify all received signal to the process$docker attach ID
Note: the attach command allows you to view or influence a running container. You can attach the same container at the same time. You can also break out of a container, which is from the CTRL-C.
Save and load the image (save, load)
When you need to migrate an image from one machine to another, you need to save the image and load the image.
# Save the image to a tar package;-o,-output= "" Write to an file$docker save image_name-o file_path# loads an image in tar package format;-I,-input= "" Read from a tar archive file$docker load-I file_path# machine a$docker save image_name > / home/save.tar# copy save.tar to machine b using scp, and then: $docker load < / home/save.tar "
Log in to registry server (login)
# Log in to registry server;-e,-- email= "" Email;-p,-- password= "" Password;-u,-- username= "" Username$docker login "
Publish image (push)
# publish docker image $docker push new_image_name
Build a container based on Dockerfile
# build-- no-cache=false Do not use cache when building the image-Q,-- quiet=false Suppress the verbose output generated by the containers-- rm=true Remove intermediate containers after a successful build-t,-- tag= "Repository name (and optionally a tag) to be applied to the resulting image in case of success$docker build-t image_name Dockerfile_path so far, the study of" what commands are commonly used in Docker "is over, hoping to solve everyone's 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.