Compose: Support docker-compose login

Created on 27 Aug 2016  路  8Comments  路  Source: docker/compose

I have a CI build in GitLab that uses docker-compose to deploy on a remote docker host. The CI build can do everything using only the docker-compose binary, except for one thing. The images are coming from a private registry which requires authentication (the registry in GitLab). So I need to run docker login before I do docker-compose pull. This means I have to install the full docker package in the CI build just to execute the docker login command. I propose that login in is added directly to docker-compose and work the same way as in docker. So I can run something like docker-compose login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY.

arecli kinquestion stale

Most helpful comment

This also renders the docker/compose image useless for private registries.

I understand the duplication reason, but then the login/logout functionality should probably be de-duped into a third component which can then be used by both docker and docker-compose.

All 8 comments

This should fix the root cause of issue #3782 as well. From the bug report and the logs in #3782 it looks like compose tries to reuse the ~/.docker/config.json auth config file created by the docker client on docker login.

This is a dependency on an external file created by another binary on the system - something we should probably avoid.

Pre-existing auth config from the docker client can still be considered if no explicit docker-compose login has been performed beforehand.

any update on that?

Any news?

Because of the intricacies of authentication in Docker, we have no plans to add a login subcommand at this time, as it would duplicate functionality with the Docker CLI and create a lot of additional complexity and potential for issues in Compose.

Thank you for your understanding.

This also renders the docker/compose image useless for private registries.

I understand the duplication reason, but then the login/logout functionality should probably be de-duped into a third component which can then be used by both docker and docker-compose.

@buffcode You can use the compose image and share credentials with the user in the host if you run through the script in https://github.com/docker/compose/blob/master/script/run/run.sh

You can see that it uses the volume in the $HOME directory of the user who runs it:

https://github.com/docker/compose/blob/90185117501861558f265f5ac83bddb1aca0bad2/script/run/run.sh#L46

You can download it with:

$ sudo curl -L --fail https://github.com/docker/compose/releases/download/1.22.0/run.sh -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose

As it is shown in the docs: https://docs.docker.com/compose/install/#install-as-a-container

Just make sure that the user that make the docker login is the same that run docker-compose (and see if one is run with sudo and the other not, in which case the $HOME may end up being your user home directory in one command and /root in another).

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because it had not recent activity during the stale period.

Was this page helpful?
0 / 5 - 0 ratings