Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build docker Private Warehouse from scratch

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people don't understand the knowledge points of this article "how to build docker private repository from zero", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "how to build docker private repository from zero".

Experimental environment:

Centos7 64 bit

ubuntu16.04 64 bit (for testing private repositories)

Part 1: Installing docker

#install dockersudo via yum source yum -y install docker#start dockersudo systemctl start docker#boot sudo systemctl enable docker

Part 2: Operation of Mirrors

Find and download docker images (for example centos)

#find centos mirror docker search centos#download centos mirror sudo docker pull docker.io/centos:latest

List Mirrors

sudo docker image ls

removing mirroring

sudo docker image rm 4655e9997674

Part 3: Handling of containers

Create container and enter

sudo docker run -t -i --name zhaoolee-centos docker.io/centos:latest /bin/bash

Parameter description: -t Assign a pseudo-terminal and bind it to the container's standard input, -i Leave the container's standard input open

View all containers

sudo docker ps -a

start the container

sudo docker start zhaoolee-centos

View currently running containers

sudo docker ps

stop the container

sudo docker stop zhaoolee-centos

Enter container environment

sudo docker attach zhaoolee-centos

Send commands inside the container

We can send commands inside the container without going into the container environment

sudo docker exec zhaoolee-centos touch 123.txt

delete a container

After stopping the container, you can delete the container

sudo docker rm zhaoolee-centos

(Optional)docker Advanced Command

Exchange files docker cp

The docker cp command enables file exchange between containers and external environments.

We create a new 123.txt file inside the docker container, copy it to the external environment, create a new 456.txt file in the external environment and copy it to the docker container (as shown below)

Even if the container is inactive, it is still possible to exchange files

Publish modified container as mirror

#Publish the modified container as an image, `-a` indicates the author, `-m` indicates the description of this modification sudo docker commit -a "zhaoolee" -m "add 123.txt 456.txt" zhaoolee-centos Zhaoolee-centos:0.1#Create a container based on the new image sudo docker run -t -i --name my-centos zhaoolee-centos:0.1 /bin/bash

View mirrored information

#View newly created mirror information sudo docker history zhaoolee-centos:0.1

View change logs within containers

sudo docker diff zhaoolee-centos

View Mirrors and Container Details

#View details of mirror sudo docker inspect zhaoolee-centos:0.1 #View details of container sudo docker inspect zhaoolee-centos

Part 4: Creating a Private Repository

1. Download an image of the private repository registry server

sudo docker pull registry:latest

2. Create a registry server container

sudo docker run -d -p 5000:5000 --name server-registry -v /tmp/registry:/tmp/registry docker.io/registry:latest

Parameter description-d container runs on the backend, -p 5000:5000 runs on port 5000 of the container and maps to port 5000 of the external system, --name server-registry container Name server-registry, -v /tmp/registry /tmp/registry Mount the host directory/tmp/registry to the container directory/tmp/registry

3. Label local mirrors and place them in local repositories

Label local mirrors

sudo docker tag zhaoolee-centos:0.1 localhost:5000/zhaoolee-centos:0.1

Push marked local images to repository

sudo docker push localhost:5000/zhaoolee-centos:0.1

4. Testing the availability of local repositories

In the virtual machine intranet, start another ubuntu16.04 virtual machine, unbutu16.04 try to get the image just created from centos7 Zhaoolee-centos:0.1

sudo docker pull 192.168.214.156:5000/zhaoolee-centos:0.1

#Fix problems during installation: Fix: error response from daemon: get https://192.168.214.156:5000/v2/: http: server gave http response to https clientech '{ "insecure-registries":["192.168.214.156:5000"] }' > /etc/docker/daemon.json The above is about the content of this article "How to build docker private repository from zero". I believe everyone has a certain understanding. I hope the content shared by Xiaobian will be helpful to everyone. If you want to know more relevant knowledge content, please pay attention to the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report