Detailed explanation of common commands in Docker warehouse
- 2021-07-01 08:33:01
- OfStack
Login
docker login
Enter the username, password, and mailbox to complete the registration and login by executing the docker login command. After successful registration, the user authentication information will be stored in the. dockercfg of the local user directory.
Pull the image from the warehouse
docker pull [ Mirror name ]
Search image
docker search [ The mirror name you want to search for ]
For example:
C:\Users\kunta>docker search centos
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 5605 [OK]
ansible/centos7-ansible Ansible on Centos7 123 [OK]
jdeathe/centos-ssh OpenSSH / Supervisor / EPEL/IUS/SCL Repos - … 113 [OK]
consol/centos-xfce-vnc Centos container with "headless" VNC session … 99 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 63
imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 57 [OK]
tutum/centos Simple CentOS docker image with SSH access 45
centos/postgresql-96-centos7 PostgreSQL is an advanced Object-Relational … 39
kinogmt/centos-ssh CentOS with SSH 29
We can divide them into two categories according to whether the mirror image is officially provided. One is the basic image like centos, which is called the basic or root image. These images are created, verified, supported and provided by Docker.
The other one is a mirror like ansible/centos7-ansible, which is provided by other unofficial users or organizations, generally by adding some functions to the basic mirror and then submitting it for everyone to use. Mirrors like ansible/centos7-ansible, which are maintained by a user or organization named ansible, are prefixed with the user name to indicate a user's repository.
Automatically create
Auto-Create (Automated Builds) functionality is 10 points handy for frequent upgrades to in-image programs. Sometimes a user creates an image, installs a piece of software, and needs to update the image manually if the software releases a new version.
The automatic creation function enables users to specify and track projects on target websites (currently supporting GitHub or BitBucket) through DockerHub, and automatically perform creation once new submissions are found.
To configure automatic creation, include the following steps:
Create and log in to Docker Hub and the target website; * Connect the account to Docker Hub in the target site. Configure 1 auto-create in Docker Hub. Select projects (which need to contain Dockerfile) and branches in 1 target website. Specify the location of Dockerfile and submit the creation.
After that, you can track the status of each creation in the Auto Create page of DockerHub.
Create and use private repositories,
After installing Docker, you can simply build 1-set of local private warehouse environment through the official registry image:
docker run -d -p 5000:5000 registry
When the docker run command is executed, if it is found that there is no corresponding image locally, it will pull the image before running.
By default, the repository is created in the/tmp/registry directory of the container. You can use the-v parameter to store the image file locally on the specified path.
For example, the following example puts the uploaded image in the/opt/data/registry directory:
docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry
At this point, a private warehouse service will be started locally, and the listening port is 5000.
Actual combat
First, build a private warehouse on a server machine, and its address is 10.0. 2.2: 5000. Then try to upload and download the image from the machine.
View existing images locally:
C:\Users\kunta>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hub.c.163.com/kuntang/lingermarket latest c7a70a3810cf 23 months ago 418MB
ubuntu2 16.04 1196ea15dad6 2 years ago 336MB
ubuntu latest 1196ea15dad6 2 years ago 336MB
hub.c.163.com/public/ubuntu 16.04-tools 1196ea15dad6 2 years ago 336MB
hub.c.163.com/public/centos 6.7-tools b2ab0ed558bb 2 years ago 602MB
Use the docker tag command to mark the mirrored repository as a private repository machine subaddress (format: docker tag IMAGE [: TAG] [REGISTRYHOST/] NAME [: TAG]):
docker tag ubuntu2:16.04 10.0.2.2:5000/test
docker images
Upload the image using the docker push command:
docker push 10.0.2.2:5000/test
Viewing the image of private warehouse with curl
curl http://10.0.2.2:5000/v1/search
You can see that the mirroring was successful last time.
You can now download this image from any machine that has access to the 10.0. 2.2 address:
docker pull [ Mirror name ]
0