In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1 preface
This article introduces 16 commonly used Docker commands, first give you a simple concept, some of the commands are more complex.
2 commonly used commands
2.1 docker images
The docker images command is used to view a list of mirrors, and the docker images-a command is used to view all mirrors. There are sub-images in the images built by the docker build command. You can view all the sub-images contained in the constructed images through the docker images-a command, and there are no sub-images in the images pulled by the docker pull command.
The image information pulled by the docker images command is the image name, version number, image ID, image creation time and image size from left to right. The image ID is the unique ID of the image. You can label the image with the docker tag command to generate multiple images with different names.
2.2 docker login
The docker login command is used to log in to the docker repository. To pull an image from a private image repository or push an image to the image repository, you need to log in to the image repository with the docker login command before performing the operation.
Docker login-username= registry.cn-hangzhou.aliyuncs.com
2.3 docker pull
The docker pull command is used to pull the image. You do not need to log in to pull an image from the docker official image warehouse. You can directly pass in the image name and version number. You do not need to log in to pull the image from the three-party public image warehouse, but you need to pass in the domain name, image name and version number of the three-party image warehouse. You need to log in to pull the image from the three-party private image warehouse through the docker login command, and you can pull the image only after the login is successful.
Pull from the official image repository of docker
Docker pull alpine:3.7
Pull from the tripartite public image warehouse
Docker pull registry.cn-hangzhou.aliyuncs.com/jiuxi-blockchain/alpine:3.7
Pull from the tripartite private image repository
Docker login-username= registry.cn-hangzhou.aliyuncs.com
Docker pull registry.cn-hangzhou.aliyuncs.com/jiuxi-blockchain/alpine:3.7
Docker logout registry.cn-hangzhou.aliyuncs.com
2.4 docker tag
After pulling an image from a three-party image repository, the image name will contain the domain name of the three-party image repository, as shown below:
The image name is not the desired image name. You can label the image with the docker tag command at this time. When tagging, you must enter the image ID, the new image name and the image version number.
Docker tag 6d1ef012b567 alpine:3.7
2.5 docker rmi
After tagging the image, two images exist at the same time, as shown in the following figure:
The original pulled image name and the desired image name exist at the same time. You can delete the unwanted image name by using the docker rmi command. When deleting an image, you must pass in the image name and the image version number.
Docker rmi registry.cn-hangzhou.aliyuncs.com/jiuxi-blockchain/alpine:3.7
2.6 docker logout
The docker logout command is used to exit the image repository. After the operation with the image repository ends, for security reasons, log out of the logged-in image repository.
Docker logout registry.cn-hangzhou.aliyuncs.com
2.7 docker run
The docker run command starts the Docker container. When starting the Docker container, you can specify many parameters, such as container name, port mapping, file directory mapping, network bridging, environment variables, initialization script, and so on. This command will be explained in depth in the following "Docker Container" article. The simplest example is given in this article.
Docker run-it alpine:3.7 sh
2.8 docker ps
The docker ps command is used to view running containers, and the docker ps-a command is used to view started containers, including creating containers that are not running and have stopped running, as shown in the following figure:
The image information pulled by docker ps command is container ID, image, startup command, container creation time, container running status, port mapping relationship, and container name from left to right. The container has three running states: Up indicates that the container is running; Created indicates that the container was created but failed to start successfully; and Exited indicates that the container has stopped running.
Docker ps-a
2.9 docker cp
The docker cp command is used to copy the specified files from the server directory to the specified directory within the container.
Docker cp file1: / path2/
2.10 docker exec
The docker exec command is used to log in to a running container, which can be manipulated after logging in.
Docker exec-it bash
2.11 docker logs
The docker logs command is used to view the logs of a specific container, which can be tracked continuously through the docker logs-f command, which is similar to the tail-f command.
Docker logs-f
2.12 docker start
The docker start command is used to start a container that is not running. It can only start the container and cannot modify the startup parameters of the container.
Docker start
2.13 docker stop
The docker stop command is used to stop a container that is running.
Docker stop
2.14 docker rm
The docker rm command is used to delete a container that is not running. When you use the docker rm command to delete a running container, the command fails.
Docker rm
2.15 docker build
The docker build command is used to create a mirror. To create an image, you must rely on another source image. Generally, alpine, java, centos and other basic images are used as the source image. The docker build command needs to read the Dockerfile file and generate an image according to the configuration of the Dockerfile file. The process of creating an image is not described too much here, and the command will be explained in depth in the subsequent "Docker Custom Image" article.
2.16 docker push
The docker push command is used to push an image to the image repository. To push an image, you must log in first.
Log in to the docker official image repository:
Docker login
Log in to the three-party image repository:
Docker login-username= registry.cn-hangzhou.aliyuncs.com
You do not need to specify the domain name of the image repository when you push to the official docker image warehouse. When you push to the three-party repository, you must tag the container with the docker tag command and add the domain name of the three-party repository to the image name before you push.
Push to the official image repository of docker:
Docker push alpine:3.7
Push to the three-party image warehouse
Docker tag 6d1ef012b567 registry.cn-hangzhou.aliyuncs.com/jiuxi-blockchain/alpine:3.7
Docker push registry.cn-hangzhou.aliyuncs.com/jiuxi-blockchain/alpine:3.7
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.