docker-compose -H does not work with compose 2.11.0
BUG REPORT INFORMATION
Description
The remote socket support stopped working with compose 2.11.0.
Steps to reproduce the issue:
- Create an example docker-compose file
- Try to start the container at a remote host using
docker-compose -H ssh://<<Remote host to deploy at>> up
Describe the results you received: Instead of deploying to the remote server it deploys on the localhost.
Describe the results you expected: Deploy the container on the remote host.
Additional information you deem important (e.g. issue happens only occasionally):
Using DOCKER_HOST=ssh://<<Remote host to deploy at>> docker-compose up still works as expected.
Output of docker compose version:
Docker Compose version v2.11.0
Output of docker info:
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.9.1)
compose: Docker Compose (Docker Inc., v2.11.0)
Server:
Server Version: 20.10.18
Storage Driver: overlay2
Additional environment details:
@ulyssessouza looks like this was introduced in https://github.com/docker/compose/pull/9817. Can you take a look?
I'm unsure if this is related, but I'm having similar issues with the --context option:
This lists my remote containers:
docker --context my_context ps
This does not:
docker --context my_context compose -p my_fixed_project_name ps
Don’t know if this helps but:
docker -H <<Remote host>> compose up also does not work.
This makes compose unusable for me.
@sphinxc0re in the meantime, as mentioned by @niklas-rittmann, you can use DOCKER_HOST=ssh://<<Remote host>> docker compose [xxx] to circumvent this issue.
Nope, this does not work either.
@sphinxc0re Strange, I tested this on two separate machines + using the docker image and on all machines it seemed to work just fine.
Just tested this again with -p my_project_name specified. The workaround works now.
Also doesn't work for me
(venv) kaan@ubuntu-vm:~/Desktop/DjangoProject$ DOCKER_HOST=ssh://[email protected] docker compose -f docker-compose.base.yml -f deploy/docker-compose.yml --env-file deploy/env_file ps
Cannot connect to the Docker daemon at http://docker.example.com. Is the docker daemon running?
quick edit, it was due to bad permissions on remote host, this line works
DOCKER_HOST=ssh://[email protected] docker compose -f docker-compose.base.yml -f deploy/docker-compose.yml --env-file deploy/env_file ps
it doesn't display the correct error when the permissions are wrong so its a little misleading. This is what I did to enable docker for ubuntu user
groupadd docker
usermod -aG docker ubuntu
chown root:docker /var/run/docker.sock
chown -R root:docker /var/run/docker
This is fixed by #9871, which will be in the next Compose release (which I'm in the process of tagging 🙂).