1

I would like to deploy an application to a remote server by using docker-compose with a remote context, following this tutorial.

The Dockerfile contains

FROM ubuntu

The docker-compose.yml contains

version: "3.8"
services:
  ubuntu_test:
    build: .   

The remote context remote is set as ssh://root@host

When I run docker-compose --context remote up, it crashes with the following error message

runtime/cgo: pthread_create failed: Resource temporarily unavailable
runtime/cgo: pthread_create failed: Resource temporarily unavailable
SIGABRT: abort
PC=0x7fb21d93bfb7 m=3 sigcode=18446744073709551610

goroutine 0 [idle]:
runtime: unknown pc 0x7fb21d93bfb7
stack: frame={sp:0x7fb21aee9840, fp:0x0} stack=[0x7fb21a6ea288,0x7fb21aee9e88)
[...]
ERROR: Couldn't connect to Docker daemon at http+docker://ssh - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

What is already working

  • Copying the source code to the remote server, logging in and running docker-compose up
  • Unpacking docker-compose into the corresponding docker commands
    • docker --context remote build .: works
    • docker --context remote run ubuntu: works
  • Using docker-compose --context remote build on the local machine to build the images on the remote server

In summary, everything works except for docker-compose --context remote up and I can't for the live of me figure out why. Everything I got is this cryptic error message (but obviously, Docker is running on the remote server, otherwise docker with remote context would fail).

Edit: My problem can be reduced to: What is the difference between docker --context remote run ubuntu and docker-compose --context remote up (as defined in my case)?

Maxim Schmidt
  • 147
  • 12
  • I dont see how you can compare the two commands. `docker-compose` (which is an alternative to `docker build`) creates a "Docker Image" whereas `docker run` is used to run a container from an image that already exists (either in local machine or on a container registry server say docker-hub or gcr.io) – Piyush Singh Mar 06 '21 at 06:23
  • 1
    So far as remote deployment is concerned, I'm not 100% sure but your demon seems to not have the proper `DOCKER_HOST` while you're trying to `docker-compose`, so maybe you could use this `DOCKER_HOST=“ssh://user@remotehost” docker-compose up -d` and then try to `docker run` remotely. For the second part you'll need to have the correct cert path etc. This may help https://stackoverflow.com/a/44447171/9563006 – Piyush Singh Mar 06 '21 at 06:38
  • I think the main purpose of `docker-compose` is to conveniently start multi-container applications. So, it's more of an extended version of `docker run` – Maxim Schmidt Mar 07 '21 at 09:42
  • I tried setting the `DOCKER_HOST` explicitly, but it produced the same result. At least this means that `docker-compose` is reading the context properly (which is correct since it works with `docker`) – Maxim Schmidt Mar 07 '21 at 09:49
  • I see. `docker-compose` can build and run multiple dockerfiles. I have never used it. – Piyush Singh Mar 07 '21 at 10:02
  • `ERROR: Couldn't connect to Docker daemon at http+docker://ssh - is it running?` suggests your local Docker daemon couldnt ssh into your server. Check whether your server has the Docker daemon running properly. I still doubt that the actual issue is `DOCKER_HOST` in your `docker env` though. Check this https://stackoverflow.com/a/29111083/9563006 – Piyush Singh Mar 07 '21 at 10:04
  • I don't use `docker-machine` at all. Docker is running as a systemd daemon on the remote host. – Maxim Schmidt Mar 07 '21 at 10:16
  • I should add that, yesterday, I tried to set up Docker Swarm on my server. It didn't work because the VSP I use (Strato) didn't provide a certain kernel module (br_netfilter). I am beginning to suspect that the problem I mention here is also the fault of a non-standard Ubuntu installation. – Maxim Schmidt Mar 07 '21 at 10:18
  • Does it work if you manually ssh into the server and build it locally there? – Piyush Singh Mar 07 '21 at 11:13
  • Yup. That's the whole dilemma. It's a tad sad that I couldn't figure this out, but I don't think it's worth it anymore. Thank you for your suggestions, though. Very much appreciated. – Maxim Schmidt Mar 07 '21 at 12:08
  • Can you ssh to the host with password or with identity? With other words, when you ssh are you asked to type password to access the host? Also are you accessing the host as a root or as a normal user? – jordanvrtanoski Mar 07 '21 at 16:50
  • I have key-based authorization enabled, i.e. I don't need to type in a password. I am accessing the host as root. – Maxim Schmidt Mar 07 '21 at 18:36
  • For key authorization - do you use default key from `.ssh/id_rsa` or other location? could be that docker is not aware of custom key, you could try to use `ssh-add` or configure host using `.ssh/config` – jazgot Mar 08 '21 at 11:38
  • I have a custom key, yes, but I use `.ssh/config`. I just tried it on my Ubuntu machine using the standard key, with a slightly older version of docker-compose -- exactly the same result. `docker-compose build` works, but no luck with `docker-compose up`. My best guess is that it's the server's fault. It doesn't even run Swarm. I will probably switch to DigitalOcean (or similar) in the future. – Maxim Schmidt Mar 09 '21 at 16:29

0 Answers0