Authenticating private repositories when running docker/compose in container

188 Views Asked by At

I'm using GCP's container-optimized image to run a number of containers through docker compose. As mentioned in this article, public repositories are working fine but I can't figure out why docker login in the host machine is not reflected in the docker-compose container.

docker login -u "bohemia" -p"randompass" docker.coolregistry.com

which gives:

WARNING! Your password will be stored unencrypted in /home/bohemia/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded

I'm not using any credential helper, so mounting the path to the docker config (with the updated token) to the container running compose should work.

docker run -it --rm \
    -v "/var/run/docker.sock:/var/run/docker.sock" \
    -v "$HOME/.docker/config.json:$HOME/.docker/config.json" \
    -v "$PWD:$PWD" \
    -w="$PWD" \
    docker/compose:1.24.0 up -d

But I'm still getting the following error:

...
Pulling container (docker.coolregistry.com/this_image:latest)...
ERROR: Get https://docker.coolregistry.com/v2/this_image/manifests/latest: no basic auth credentials

What am I missing here?

0

There are 0 best solutions below