Home > Operation and Maintenance > Docker > How to build a local private warehouse with Docker (detailed example)

How to build a local private warehouse with Docker (detailed example)

WBOY
Release: 2022-02-08 17:29:09
forward
3049 people have browsed it

This article brings you relevant knowledge about building a local private warehouse in docker, including using registry images to create private warehouses and checking whether the build is successful and other related issues. I hope it will be helpful to everyone.

How to build a local private warehouse with Docker (detailed example)

Use the registry image to create a private warehouse

docker run -itd --restart always --name docker-hub -p 5000:5000 -v /opt/data/registry:/var/lib/registry registry
Copy after login

View the private warehouse that does not store the image yet, so it is displayed as empty

curl -XGET 127.0.0.1:5000/v2/image_name/tags/list
Copy after login

Create a new image (named with ip: port), and try push

ifconfig | grep inet
Copy after login

How to build a local private warehouse with Docker (detailed example)
I know that the local IP is 172.17.0.1

  1. Create a new container
docker tag ubuntu:18.04 172.17.0.1:5000/test
Copy after login

How to build a local private warehouse with Docker (detailed example)
2. push image

docker push 172.17.0.1:5000/test
Copy after login
Copy after login

If

Get https://172.17.0.1:5000/v2/: http : server gave HTTP response to HTTPS client

How to build a local private warehouse with Docker (detailed example)
Don’t panic, just change the machine configuration (/etc/docker/daemon.json). First of all, avoid being handicapped. First use cp to back up

cp daemon.json daemon.json.bak
Copy after login

and then change the content of daemon.json

{"insecure-registries":["172.17.0.1:5000"]}
Copy after login

The value of insecure-registries is an iterable list, you can add ip:port by yourself

How to build a local private warehouse with Docker (detailed example)
Remember to change to your own IP and port

Restart Docker

systemctl restart docker
Copy after login

Finally push successfully

docker push 172.17.0.1:5000/test
Copy after login
Copy after login

How to build a local private warehouse with Docker (detailed example)

##Check whether the build is successful /Try to pull the file you just pushed

Delete the original image

docker rmi 172.17.0.1:5000/test  #将原来push的镜像删掉,方便等会pull检验echo 'DOCKER_OPTS="--insecure-registry 172.17.0.1:5000/test' >> /etc/default/docker
Copy after login
If it is just an experiment, writing 0.0.0.0/0 (all ip ports) is not impossible


How to build a local private warehouse with Docker (detailed example)

service docker restart		#重启服务docker pull 172.17.0.1:5000/test	#pull下之前push的镜像
Copy after login

How to build a local private warehouse with Docker (detailed example) After downloading, you can change the name of the image under pull to facilitate future calls.

Recommended learning: "

docker video tutorial

The above is the detailed content of How to build a local private warehouse with Docker (detailed example). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template