Detailed explanation of common commands in Docker repository

Detailed explanation of common commands in Docker repository

Log in

docker login

Complete the registration and login by executing the docker login command and entering the username, password, and email address. After successful registration, the user authentication information will be saved in the .dockercfg file in the local user directory.

Pull the image from the repository

docker pull [image name]

Search Mirror

docker search [image name to search]

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 the images into two categories based on whether they are officially provided. One is a base image like centos, called a base or root image. These images are created, verified, supported, and provided by Docker.

The other type is an image like ansible/centos7-ansible, which is provided by other unofficial users or organizations. Generally, some features are added to the basic image and then submitted for release for everyone to use. For example, the ansible/centos7-ansible image is maintained by a user or organization named ansible and has a username as a prefix, indicating that it is a repository for a certain user.

Automatic creation

The Automated Builds feature is very convenient for frequently upgrading programs in the image. Sometimes, a user creates an image and installs a certain software. If a new version of the software is released, the image needs to be manually updated.
The automatic creation function allows users to specify a project on a target website (currently supports GitHub or BitBucket) for tracking through DockerHub. Once a new submission is found in the project, it will be automatically created.

To configure automatic creation, follow these steps:

  1. Create and log in to Docker Hub, and the target website; * Connect your account to Docker Hub in the target website.
  2. Configure an automatic build in Docker Hub.
  3. Select a project (including Dockerfile) and branch in the target website.
  4. Specify the location of the Dockerfile and submit the build.

Afterwards, you can track the status of each build in the Automatic builds page in DockerHub.

Creating and using private repositories,

After installing Docker, you can easily build a 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 first pull the image and then run it.

By default, the repository is created in the /tmp/registry directory of the container. The -v parameter can be used to store the image file in a specified local path.
For example, the following example puts the uploaded image into 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, listening on port 5000.

Actual Combat

First, build a private warehouse on a server machine, whose address is 10.0.2.2:5000. Then try to upload and download the image from the machine.
Check the 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 image repository as a private repository machine address (the format is: docker tag IMAGE[:TAG] [REGISTRYHOST/]NAME[:TAG]):

docker tag ubuntu2:16.04 10.0.2.2:5000/test
docker images

Use the docker push command to upload the image:

docker push 10.0.2.2:5000/test

Use curl to view the image of the private warehouse

curl http://10.0.2.2:5000/v1/search

It can be seen that the mirroring was successful last time.

Now you can download this image from any machine that can access the 10.0.2.2 address:

docker pull 10.0.2.2:5000/test

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of common commands for network configuration of containers in Docker
  • Summary of common commands in Dockerfile
  • Docker common commands summary (practical version)
  • Summary of Docker's commonly used commands for clearing container images
  • Detailed explanation of common Docker commands

<<:  Use PHP's mail() function to send emails

>>:  Detailed explanation of the interaction between React Native and IOS

Recommend

This article teaches you how to import CSS like JS modules

Table of contents Preface What are constructible ...

Pure CSS custom multi-line ellipsis problem (from principle to implementation)

How to display text overflow? What are your needs...

Why does using limit in MySQL affect performance?

First, let me explain the version of MySQL: mysql...

How to configure MySQL on Ubuntu 16.04 server and enable remote connection

background I am learning nodejs recently, and I r...

Regular expression usage in CSS selectors

Yes, CSS has regular expressions too (Amen) Two p...

How to set up the use of Chinese input method in Ubuntu 18.04

In the latest version of Ubuntu, users no longer ...

Four ways to modify the default CSS style of element-ui components in Vue

Table of contents Preface 1. Use global unified o...

Detailed explanation of display modes in CSS tags

Label display mode (important) div and span tags ...

React concurrent function experience (front-end concurrent mode)

React is an open-source JavaScript library used b...

Pagination Examples and Good Practices

<br />Structure and hierarchy reduce complex...

Install Centos7 using Hyper-v virtual machine

Table of contents introduce Prepare Download syst...