I can’t really find any information on how docker-compose
work with --context
All I’ve found is this blog post
If I have a docker-compose.yml
on my server I can run docker-compose up -d
etc. and it works just as it should.
If I take this exact docker-compose.yml
file and put it on my local computer then add a docker context
to my server like this:
docker context create remote --docker "host=ssh://username@servername"
Note: The username here is the same I use when SSH to the server.
Then try to run for example
docker --context remote ps
I will get the information from my remote server. I can also create containers and everything.
However, if I have run docker-compose up -d
on the server already and try to take it down from my computer like this:
docker-compose --context remote down
It doesn’t work. I don’t get any information at all.
No matter what I do it wont work. However if I try to up
it again from my local computer I will get an error saying the container name is in use but if I run docker-compose --context remote ps
it won’t show anything.
If I go back to the server and take the container down and then from my computer again try to run up
it will work…
So it seems like docker-compose --context
is somehow getting it’s own “session” per user even though it’s the same user that started it locally on the server as the context logs in to. This is also true if I do the exact same on a different computer with the same username and everything.
Does anyone know if this is by desing, a bug or can be fixed with a Docker config or an entry in the docker-compose.yml
?
What I wanted to accomplish was to let a group of users from their local computers up/down a set of containers with docker-compose with context
being logged in with the same username…
We have a “stage” service that a groups of 3 people need to be able to up/down/restart etc. to do some testing and --context
would make is so much easier for them to use than use SSH to the server and run the commands from there.