Reputation: 672
I'm working with DigitalOcean, specicially the 1-click Docker droplet.
Docker is running on the droplet, and the socket file is at /var/run/docker.sock on the droplet.
I have docker and docker-compose also installed locally on my machine.
I have a docker-compose.yml that works locally on my machine.
I have the public-key on the droplet and the private key added to ssh-add on my local machine. My ssh-key has a passphrase.
I can ssh into my DigitalOcean droplet from my local machine without any problem or password prompts.
Port 22 is open on the droplet.
Edit: docker-compose on both machines is > 1.28
Given these facts, this should work, according to all of the tutorials and documentation that I've read:
docker-compose -H "ssh://root@<my-digital-ocean-droplet-ip-here>" up -d
But it does not work. I get this:
ssh: connect to host <my-digital-ocean-droplet-ip-here> port 22: Connection timed out
ERROR: Couldn't connect to Docker daemon at http+docker://ssh - is it running?
I can't figure it out. I've tried using docker contexts, environment variables for the host, nothing is working. Is there anything I'm missing?
Edit- one more detail. I haven't seen anything to suggest that this would be important, but the end of my public-key says "azuread/ ". Again, this doesn't interfere with normal ssh.
Edit- Here's the docker-compose.yml:
version: '3.9'
services:
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: myhardrootpassword
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress_admin_guy
MYSQL_PASSWORD: myhardpassword
volumes:
- db_data:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: pma
environment:
PMA_HOST: db
PMA_PORT: 3306
restart: always
ports:
- 8080:80
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- 8000:80
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress_admin_guy
WORDPRESS_DB_PASSWORD: myhardpassword
WORDPRESS_DB_NAME: wordpress
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
volumes:
db_data: {}
Edit: Here's the version numbers:
Local: docker --version
Docker version 20.10.6, build 370c289
Local: docker-compose --version
docker-compose version 1.29.1, build c34c88b2
Server: docker-compose --version
docker-compose version 1.27.4, build 40524192
Server: docker --version
Docker version 19.03.13, build 4484c46d9d
Server: ssh -V
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f 31 Mar 2020
https://docs.docker.com/engine/reference/commandline/dockerd/ https://www.docker.com/blog/how-to-deploy-on-remote-docker-hosts-with-docker-compose/ https://github.com/docker/compose/issues/4181 https://blog.mikesir87.io/2019/08/using-ssh-connections-in-docker- How to run docker-compose on remote host?
Upvotes: 9
Views: 4014
Reputation: 95
ERROR: Couldn't connect to Docker daemon at http+docker://ssh - is it running?
I had this issue a while back and it was auth related. My remote user was not root and did not have access to the docker group / daemon but I see you are using root here but it could be worth a check.
This is where I found my solution
Note that there’s no way to pass sudo via this syntax, so you’ll need to ensure that the user you specify on the command line has the ability to run docker commands without privilege escalation. (You could add them to the “docker” group on the remote system, for example.)
I know you are using key-based auth with a passphrase and not password based auth but... it is already acknowledged that password based does not work and there are some ongoing issues related such as this one where a user also mentions a similar scenario where docker -H ssh://[email protected] ps
in fact works for them despite docker-compose
throwing them issues.
Upvotes: 1