Steps for Docker to build its own local image repository

Steps for Docker to build its own local image repository

1. Environment and preparation

  • 1. Ubuntu 14.04
  • 2.Docker environment

2. Construction process

1. Change the mirror source (because the default one is too slow, the domestic one is faster)

sudo vim /etc/default/docker
Enter the following parameters:
DOCKER_OPTS="--registry-mirror=http://hub-mirror.c.163.com" //NetEase, you can also use daoClouds

If it is a newly installed Ubuntu environment, execute the following command (of course you can also use vi, or write directly)

sudo apt-get update //Update apt-get source to prevent download errors sudo apt-get install vim -y //Download vim

2. Start Docker and pull the registry image source

sudo service docker start //Start docker
sudo docker pull registry //Download the registry image

3. After downloading, check whether the download is successful

sudo docker images 

4. After downloading, start the container and mount the data mapping in the container on the directory you specify. Here, /opt/data/registry is the directory stored on the host machine.

mkdir -p /opt/data/registry //Create directory sudo docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry 
  --name private_registry registry //Start the container -d: Allow the container to run in the background -p: Specify the mapping port (the former is the port number of the host machine, and the latter is the port number of the container)
-v: data mount (the former is the host directory, the latter is the container directory)
--name : Give the running container a name 

Then check whether the container is started successfully

sudo docker ps 

5. Check the host machine's IP address

ifconfig

6. Change the docker configuration file and add your own private library address. When docker starts, it will load /etc/init/docker.conf. After reading the configuration file, it is found that it will load the /etc/default/docker file, so you only need to write the private library address to /etc/default/docker

sudo vim /etc/default/docker
Change DOCKER_OPTS to the following:
DOCKER_OPTS="--registry-mirror=http://hub-mirror.c.163.com --insecure-registry 192.168.147.129:5000"
**Port 5000 must be added. The host machine accesses port 80 by default. If you don’t want to add it, you can map port 5000 of the container to port 80 of the host machine when starting the container.

After modification, restart the container and start the registry service

sudo service docker restart //Restart the container sudo docker start private_registry //Restart the registry service

The above five steps have built a private library.

3. Testing

1. Pull an image and tag it (using busybox as an example, because busybox is relatively small)

sudo docker pull busybox:latest //Pull the image sudo docker tag busybox:latest 192.168.147.129:5000/busybox

2. Submit the tag image to your local image repository

sudo docker push 192.168.147.129:5000/busybox

3. Delete all busybox images and check

sudo docker rmi busybox 192.168.147.129:5000/busybox //Delete the busybox image sudo docker images //Check if there is any information about the busybox image

4. Pull the busybox image from the local image repository and view it

sudo docker pull 192.168.147.129:5000/busybox
sudo docker images //View the information of 192.168.147.129:5000/busybox image 

The above indicates that the pull was successful.

IV. Reflection and Improvement

1. The above local warehouses can be accessed as long as they are in the same network

2. How to manage local warehouses more conveniently is worth thinking about

3. The above methods do not perform identity authentication, so it is also worth considering how to perform identity authentication

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • How to build a docker local image warehouse under centos7 system
  • Tutorial on how to create a private image repository with Docker
  • How to use domestic image warehouse for Docker
  • Detailed explanation of using Alibaba Cloud image repository to build foreign Docker images
  • Implementation of Docker configuration modification of Alibaba Cloud image repository
  • .NETCore Docker implements containerization and private image repository management
  • Example of setting up a private Docker image repository on a CentOS 7.2 server
  • Detailed explanation of building a Docker private image repository based on Harbor
  • How to use Alibaba Cloud image repository with Docker
  • How to build a private image repository with Docker
  • How to use Docker image repository

<<:  Two ways to write stored procedures in Mysql with and without return values

>>:  MySQL 5.7 JSON type usage details

Recommend

Solution to installing vim in docker container

Table of contents The beginning of the story Inst...

mysql join query (left join, right join, inner join)

1. Common connections for mysql INNER JOIN (inner...

A brief summary of all encapsulation methods in Vue

Table of contents 1. Encapsulation API 2. Registe...

JavaScript implements random generation of verification code and verification

This article shares the specific code of JavaScri...

Linux nohup to run programs in the background and view them (nohup and &)

1. Background execution Generally, programs on Li...

Use of provide and inject in Vue3

1. Explanation of provide and inject Provide and ...

Solution to forgetting the administrator password of mysql database

1. Enter the command mysqld --skip-grant-tables (...

Detailed explanation of the process of using docker to build minio and java sdk

Table of contents 1minio is simple 2 Docker build...

Use and optimization of MySQL COUNT function

Table of contents What does the COUNT function do...