0

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?

MT0
  • 143,790
  • 11
  • 59
  • 117
Yash Nag
  • 1,096
  • 12
  • 16
  • How are you running the `docker run` command? Container OS does not maintain changes across reboots. More details are required. – John Hanley Mar 17 '21 at 19:57
  • @JohnHanley This code will be saved in the gcp meta servers as startup script. The idea is to start the instance and run the docker-compose.yml file to spawn containers. Let me know what details would be of help. – Yash Nag Mar 17 '21 at 22:36
  • The startup script does not use your user's $HOME. – John Hanley Mar 17 '21 at 23:16

0 Answers0