The login

docker login
Copy the code

Register and login by executing the docker login command to enter the user name, password, and email address. After successful registration, user authentication information is stored in the. Dockercfg file of the local user directory.

Pull the mirror from the warehouse

Docker pull [image name]Copy the code

Search the mirror

Docker Search [image name to search for]Copy the code

Such as:

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 56 [OK] centos/mysql-57-centos7 mysql 5.7 SQL Database Server 63 Imagine10255 /centos6-lnmp-php56 [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 29Copy the code

We can fall into two categories, depending on whether the mirror image is official or not. One is a base image like centos, called the base or root image. These images are created, validated, supported, and provided by Docker.

The other is a similar ansible/ Sible 7-Ansible image, which is provided by other unofficial users or organizations by adding functionality to the base image and then submitting it for public use. For example, the ansible/centos7-ansible image, which is maintained by the ansible user or organization, is prefixed with the user name, indicating a repository for a particular user.

Automatically created

Automated Builds are handy for in-image programs that need frequent updates. Sometimes a user creates an image, installs a piece of software, and manually updates the image if a new version of the software is released.

The auto-create feature allows users to track projects on each target site (currently GitHub or BitBucket) via DockerHub and automatically create projects when they find new submissions.

To configure automatic creation, follow these steps:

  1. Create and log in to Docker Hub and target websites; * Connect the account to the Docker Hub on the target site.
  2. Configure an automatic create in the Docker Hub.
  3. Select a project (Dockerfile included) and branch from the target site.
  4. Specify the location of the Dockerfile and commit creation.

After that, you can track the status of each creation on the DockerHub “Auto Create” page.

Create and use private repositories,

After Docker is installed, a set of local private warehouse environment can be simply built by the official Registry image:

docker run -d -p 5000:5000 registry
Copy the code

When the docker run command is executed, if no local image is found, the system pulls the image before running it.

By default, the repository is created in the container’s/TMP /registry directory. You can use the -v parameter to save the image file to a specified local path.

For example, the following example places the uploaded image in the /opt/data/registry directory:

docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry 
Copy the code

At this point, a private repository service will be started locally, listening on port 5000.

In actual combat

First set up a private warehouse on a server machine, its address is 10.0.2.2:5000. Then try to upload and download the image from the machine.

View an existing image 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 16.04 tools hub.c.163.com/public/ubuntu 1196 ea15dad6 2 years line 336 MB hub.c.163.com/public/centos 6.7 tools b2ab0ed558bb 2 years ago 602MBCopy the code

Docker tag IMAGE[: tag] [REGISTRYHOST/]NAME[: tag]

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

Copy the code

Upload image using docker push command:

Docker push 10.0.2.2:5000 /test
Copy the code

Curl to view a private repository image

The curl http://10.0.2.2:5000/v1/searchCopy the code

You can see that the mirror succeeded last time.

The image can now be downloaded from any machine with access to address 10.0.2.2:

Docker pull 10.0.2.2:5000 /test
Copy the code

Read more

Docker series:

  1. Docker image, container common command
  2. Docker repository common command
  3. Common network configuration commands for Docker containers