banner
lca

lca

真正的不自由,是在自己的心中设下牢笼。

Create a Docker private repository and push the image

image

Recently, after setting up the CTFd platform, I needed to create a dynamic flag range using Docker. So I set up another machine locally to create a private Docker repository and documented the process.

Creating the repository and pushing the image#

To create a private repository, we need to use the docker registry tool. 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

image

With the above two commands, the private repository is now set up. We can now upload the image 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

image

Give the pulled image a new tag:

docker tag liangchenga/dedecms5.7:v1 127.0.0.1:5000/dedecms5.7:v1

image

Push the image to the private repository.

image

In the private registry, you can also see the image that was just pushed.

image

You can also see it by accessing http://127.0.0.1:5000/v2/_catalog.

image

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 client's configuration file, which is your own host (computer). I got stuck 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"
  ]
}

image

Committing the Docker image#

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
Images from: https://wallhaven.cc/w/5g56p1

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.