34
votes

I'm using docker-compose command to run multiple containers. The problem is my docker-compose has to pull some images from the public repository and some from a private repository. What I'm planning to do is push all required images to the private repository but how can I make docker-compose pull the images from the private repository.

In short -> How to point to a private repository when the images are only available there

1
What registry are you using?Serey
we are using jfrogutkarsh31
Accessing a private image should be the same as a public one, except for the authentication part. For example, your Dockerfile base image should still be something like this: FROM private/repo:tag, and should be the same in Docker Compose. Docker Hub and Amazon ECR can be accessed by using their CLI to authenticate, in your case, I can only point you to JFrog's registry page: click hereSerey
We have an assumption that the end-user does not have the docker file. He only has a docker compose file which should automatically pull images he has mentioned in the docker-compose.yml file when when he does docker-compose uputkarsh31
Yes, so it should work the same way. I believe that JFrog gives you a custom URI for your private repository, but in order to gain access to that repository URI, you must authenticate or log-in.Serey

1 Answers

34
votes

Use docker login command. (Official doc)
Enter your credentials, and then you can pull private image, only if you have an access.

If you want to login to a self-hosted registry you can specify this by adding the server name.

docker login localhost:8080

Thanks to @herm's comment, if you want to use swarm, use : --with-registry-auth option. Personnaly, I use this command :

docker stack deploy --with-registry-auth --compose-file dev.compose.yml myProjectName