4

Since Docker Hub only allows 1 private repo, I wonder if there is any way to use Github or Gitlab, etc., to download the images? for instance:

FROM git@github.com/username/repo
...
...
...
dariush
  • 3,191
  • 3
  • 24
  • 43
  • GitHub certainly offers a container registry: https://github.blog/2020-09-01-introducing-github-container-registry/ – jonrsharpe Jun 24 '21 at 08:09
  • 1
    You mention Gitlab which is a hosted solution, right? So if you have access to a machine to run Gitlab on, you can easily run a registry on it as well. – Hans Kilian Jun 24 '21 at 08:18
  • https://about.gitlab.com/blog/2020/10/30/mitigating-the-impact-of-docker-hub-pull-requests-limits/ – Jehof Oct 11 '21 at 17:14
  • I know you've asked about solutions in github and gitlab but I would like to recommend AWS ECR, you only pay for bandwidth. – Juan Fontes Oct 13 '21 at 03:30

2 Answers2

1

Very easy with an account on gitlab.com. GitLab provides a Docker registry linked to projects and you can have unlimited private projects:

  • Create a project my-docker-project
  • Go to Package and Registries > Container registries, you should see a few commands to access your registry
  • Connect your machine to this registry using a command like:
    # Will prompt for login/pass
    docker login registry.gitlab.com
    
    • You'll need an access token or deploy token with read_registry and write_registry scopes. You can generate one via your profile Preferences > Access token. Login is the token name and password the secret token provided.
  • You can now push Docker images with commands such as:
    # Push an image 
    docker push registry.gitlab.com/YourUsernameOrGroup/my-docker-project
    
    # Push an image on a sub-path
    docker push registry.gitlab.com/YourUsernameOrGroup/my-docker-project/myimage
    

You can then use the image in a Dockerfile by referencing its URL such as:

FROM registry.gitlab.com/YourUsernameOrGroup/my-docker-project

# ...

Of course the machine from which you build must be authenticated on related GitLab registry using docker login command above (or the project must be public)

Pierre B.
  • 11,612
  • 1
  • 37
  • 58
0

both have excellent package registry services

For GitHub GPR For GitLab GCR

Both have excellent features like use it directly from Dockerfile as you want for example.

I have a public example, you can check it in Github with node.js which uses GPR to store the build image/package.