Use docker-compose to pull images from private repository

36,127

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
Share:
36,127
utkarsh31
Author by

utkarsh31

Updated on June 18, 2020

Comments

  • utkarsh31
    utkarsh31 almost 4 years

    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

  • herm
    herm almost 7 years
    Fyi: when using docker stack deploy in a swarm the --with-registry-auth option will forward the login information to other nodes.
  • cowlinator
    cowlinator about 4 years
    If you host the image on a private Artifactory Enterprise server instance, you can't just do docker login docker pull imageName. You have to do docker login artifactory.myCompany.com docker pull artifactory.myCompany.com/imageName:label. However, even after logging in on the command line, and then running my docker-compose file which contains image: artifactory.myCompany.com/imageName:label, I still get the error pull access denied for imageName, repository does not exist or may require 'docker login'
  • djsutho
    djsutho almost 3 years
    I seemed to need to add an extra pull command e.g. docker login <host> && docker compose pull && docker compose up or I'd get failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized