Welcome to the Linux Foundation Forum!

Lab 5.1 - Two questions regarding the code, tag and private repository name

Hello,

I have a couple of questions regarding this lab.

1 - When the local respository is created, why there is no name specified for the local registry?

Command below simply runs the image "registry".
$ docker run -d -p 5000:5000 --restart=always --name registry registry:2

2 - When we push the image to the repository, how do we know it will be pushed to the local repository we have just created? What happens if we have more than 1 private repository?

Command below simply tells to push the tagged image, but it does not mention where.

$ docker image push localhost:5000/myalps

However, the outcome of this commands, tells us that the image has been pushed to

Using default tag: latest
The push refers to repository [localhost:5000/myalps]
bc276c40b172: Pushed

Does it mean that the name of the respository is the same as the name of the image tag? What happens if we want to send more than 1 image to the same repository?

Thanks in advance.

Sincerely,

Josep Maria

Best Answers

  • chrispokorni
    chrispokorni Posts: 2,362
    Answer ✓

    Hi @josepmaria,

    The --name flag is used to assign the name registry to the container running the image registry:v2. In the same command, the registry repository becomes available only on port 5000 of the container host, because it was mapped as such in the command.

    One can deploy multiple isolated private registries on the same host (such as registry-v2, registry-development), but each registry will have to be mapped to a different port number on the host - since port 5000 of the host is already mapped to the registry named registry.

    When the image is tagged the registry address and the desired application name are assigned to the image. If desired, the registry's address can be aliased.

    Regards,
    -Chris

  • elliotmywebguy
    elliotmywebguy Posts: 6
    Answer ✓

    Does it mean that the name of the repository is the same as the name of the image tag?

    Yes the name of the repository is the same as the name of the "image" - so the name of your repository from the example you gave would be myalps (the tag is automatically set to the latest since you didn't explicitly upload a 'tagged' image)

    What happens if we want to send more than 1 image to the same repository?

    If you upload another version of your image "after" tagging it with a new name... for example:

    • docker tag -t myalps myalps:v1
    • docker image push localhost:5000/myalps:v1

    Then the new version will live in the /myalps repo. If you want to see the versioned/tagged images in the repo you can run this curl command:

    1. Basic command:

      curl -X GET http://localhost:5000/v2/myalps/tags/list
      
    2. Or you can pipe it through the jq command to see a prettier output

      curl -sX GET http://localhost:5000/v2/myalps/tags/list | jq
      
    3. Or to see a Catalog of all your uploaded repositories

      curl -X GET http://localhost:5000/v2/_catalog

    4. Or you can install skopeo to inspect an image on a remote registry, including your private registry

      sudo dnf install -y skopeo

      skopeo inspect --tls-verify=false docker://localhost:5000/myalps | jq .RepoTags

    5. As a side note, when using podman instead of docker you can run the following:

      podman search --tls-verify=false localhost:5000/

    For some reason docker search will not show you the contents of a private yesterday. Googling, I think it has something to do with the search command being only compatible with v1 docker API as far as searching private registries goes.

  • elliotmywebguy
    elliotmywebguy Posts: 6
    edited December 3 Answer ✓

    Hi @josepmaria,

    When we push the image to the repository, how do we know it will be pushed to the local repository we have just created? What happens if we have more than 1 private repository?

    As @chrispokorni stated, the different private registries are essentially differentiated by the port number. So you will have a different port number for each registry. Since localhost normally points back to your host system the different registries would be like:

    localhost:5000
    localhost:6000
    localhost:7000

    And so on...

    Each image needs to have that registry name as part of the images name, so the following would all go to different registries:

    docker image push localhost:5000/myalps
    docker image push localhost:6000/myalps
    docker image push localhost:7000/myalps

    And they would all have the tag of "latest" unless you already have the image tagged otherwise and specify the tag in the push.

    docker image push localhost:5000/myalps:v1

Answers

Categories

Upcoming Training