Question

SSH stops working when I run docker compose up with DOCKER_HOST

I am trying to use docker and docker-compose with DOCKER_HOST set to ssh://user@my_droplet.

Ssh works perfectly, and most docker compose commands seem to work fine except for docker compose up and down. They run for a second or two then fail with error “connect to host XXX.XXX.XXX.XXX port 22: Connection refused

error during connect: Get "http://docker/v1.41/images/redis:alpine/json": command [ssh -l user -- XXX.XXX.XXX.XXX docker system dial-stdio] has exited with exit status 255, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=ssh: connect to host XXX.XXX.XXX.XXX port 22: Connection refused

After that ssh stops working entirely. For a couple minutes I cannot connect to ssh at all, and docker commands that worked previously start failing with the same error (connection refused). Then ssh starts working again.

I tried to google this issue and it seems that for other people docker either works over ssh or not. In my case it works without any problem until I run docker compose up. And even docker compose up sometimes manages to do something before failing.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Is the Ubuntu Firewall, I see the following in the logs while running docker-compose up:

Oct 26 08:57:37 **** kernel: [ 8971.470609] [UFW LIMIT BLOCK] IN=eth0 OUT= MAC=***** SRC=*** DST=*** LEN=64 TOS=0x00 PREC=0x00 TTL=49 ID=0 DF PROTO=TCP SPT=58826 DPT=22 WINDOW=65535 RES=0x00 SYN URGP=0

I have this same problem…