Recently, after setting up the CTFd platform, I needed to create a dynamic flag target field using Docker. So I set up another machine locally to create a private Docker repository and documented the process.
Creating a Repository and Pushing Images#
To create a private repository, we need to use the docker registry
tool. First, pull an official registry image:
docker pull registry:2
- The -v parameter specifies the location where the repository will be stored locally.
docker run -d -v C:\Users\lca\Desktop\tools\registry:/var/lib/registry -p 5000:5000 --name ctfregistry registry:2
With the above two commands, the private repository is set up. Now we can upload images to the private repository and then pull, search, and upload images from the private repository.
First, pull an image that you have already uploaded to hub.docker:
docker pull liangchenga/dedecms5.7:v1
Give the pulled image a new tag:
docker tag liangchenga/dedecms5.7:v1 127.0.0.1:5000/dedecms5.7:v1
Push the image to the private repository.
You can also see the pushed image in the private repository registry.
You can also see it by accessing http://127.0.0.1:5000/v2/_catalog
.
After uploading the private image, you can pull the image from the local repository.
docker pull 127.0.0.1/镜像号:版本号
- Configure the internal network address as the repository address
🫥: Be sure to modify the configuration file of the client, which is your own host (computer). I was tricked here.
If you are using a Linux system, add the following content to /etc/docker/daemon.json:
{
"registry-mirror": [
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
],
"insecure-registries": [
"192.168.100.156:5000"
]
}
For Windows and Mac, add the above settings to Docker Engine (the IP address here is different).
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"features": {
"buildkit": true
},
"insecure-registries": [
"172.17.5.106:5000"
]
}
Committing Docker Images#
If you have made modifications to an existing image and want to commit the image to the repository, you can use the docker commit
command. docker commit
adds a new layer to the original image.
First, create a tag:
docker commit -a "lca" -m "this is a dedecms5.7 website test" 2733a49a020d 127.0.0.1:5000/mydedecms5.7:v2
-a: Image author name
-m: Comment
2733a49a020d: Original image name
127.0.0.1:5000/mydedecms5.7:v2 (new tag)
Then push it:
docker push 127.0.0.1:5000/mydedecms5.7:v2
References#
Setting Up a Private Docker Repository on Mac
Publishing Docker Images
https://blog.csdn.net/atzqtzq/article/details/115701143
Image source: https://wallhaven.cc/w/5g56p1