Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use docker-compose to pull images from private repository

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

like image 363
utkarsh31 Avatar asked Aug 08 '17 11:08

utkarsh31


People also ask

Does Docker compose up pull images?

The docker-compose spec says: pull_policy defines the decisions Compose implementations will make when it starts to pull images.

How do I access private docker images?

Log in to Docker Hub On your laptop, you must authenticate with a registry in order to pull a private image. Use the docker tool to log in to Docker Hub. See the log in section of Docker ID accounts for more information.

Do I need to login to Docker Hub to pull the images?

4 Please login prior to pull: Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.


1 Answers

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 
like image 200
callmemath Avatar answered Oct 09 '22 17:10

callmemath