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?
>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.