Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

docker-compose cli ignores current context

I created a ssh context with docker context create command, the command like docker ps -a successfully executed on the remote machine
But when I run the docker-compose up command, the containers created in local machine, by running docker context ls I ensured that I am in the remote context

Why docker-compose ignores current context?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

To activate a context for docker-compose, use:

docker context use CONTEXT_NAME

But this will change the default context and it won’t change back unless you run the command again with default as the context name. If it has to be a temporary switch of context, you can run docker-compose with -c flag:

docker-compose -c CONTEXT_NAME up

And there is also an alternative way without using context at all. docker-compose reads a number of parameters from environment and .env file (in your current directory). You can add there DOCKER_HOST variable to change the host where docker-compose will execute your commands. For example:

DOCKER_HOST=ssh://example.com

or

DOCKER_HOST=tcp://10.0.42.11:2376

The list of supported environment variables is available here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading