compose: Failed to execute script docker-compose when doing docker-compose up on SSH context

Description of the issue

Saw this post detailing how to use contexts with the upcoming docker-compose 1.26.0-rc3 release and tried to give it a shot. I then installed that pre-release version on both my local machine which has the application source code and the new EC2 machine that I want to deploy to and created a context called rolocha-staging which connects to the docker engine in the EC2 instance. Then I tried to deploy my docker-compose app to it using either

docker context use rolocha-staging
docker-compose --env-file .env.staging -f docker-compose.yml -f docker-compose.staging.yml up -d

or

docker-compose --context rolocha-staging --env-file .env.staging -f docker-compose.yml -f docker-compose.staging.yml up -d

but both approaches are resulting in the error/stacktrace included below.

If I execute in the default context (i.e. use --context default argument or docker context use default command), everything works smoothly.

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.26.0-rc3, build 46118bc5

Output of docker version

Docker version 19.03.8, build afacb8b

Output of docker-compose config (Make sure to add the relevant -f and other flags)

networks:
  app-network:
    driver: bridge
services:
  client:
    build:
      context: /Users/bibek/Developer/RoloCha/client
    command: npx serve -s build -l 4000
    container_name: rolocha-client
    environment:
      APP_CLIENT_PORT: '4000'
      APP_SERVER_PORT: '3000'
      MONGO_DB_NAME: rolocha-dev
      MONGO_HOSTNAME: db
      MONGO_PASSWORD: [redacted]
      MONGO_PORT: '27017'
      MONGO_USERNAME: admin
      NODE_ENV: development
    expose:
    - '4000'
    image: roloch4/client-staging:latest
    networks:
      app-network: {}
    ports:
    - 4000:4000/tcp
    restart: always
  db:
    container_name: db
    environment:
      APP_CLIENT_PORT: '4000'
      APP_SERVER_PORT: '3000'
      MONGO_DB_NAME: rolocha-dev
      MONGO_HOSTNAME: db
      MONGO_INITDB_ROOT_PASSWORD: ''
      MONGO_INITDB_ROOT_USERNAME: ''
      MONGO_PASSWORD: [redacted]
      MONGO_PORT: '27017'
      MONGO_USERNAME: admin
      NODE_ENV: development
    image: mongo
    networks:
      app-network: {}
    ports:
    - 27017:27017/tcp
    volumes:
    - dbdata:/data/db:rw
  nginx:
    container_name: nginx
    image: nginx:latest
    networks:
      app-network: {}
    ports:
    - 80:80/tcp
    - 443:443/tcp
    restart: always
    volumes:
    - /Users/bibek/Developer/RoloCha/nginx-conf/nginx.conf:/etc/nginx/nginx.conf:rw
  server:
    build:
      context: /Users/bibek/Developer/RoloCha/server
    command: yarn start
    container_name: rolocha-server
    environment:
      APP_CLIENT_PORT: '4000'
      APP_SERVER_PORT: '3000'
      MONGO_DB_NAME: rolocha-dev
      MONGO_HOSTNAME: db
      MONGO_PASSWORD: [redacted]
      MONGO_PORT: '27017'
      MONGO_USERNAME: admin
      NODE_ENV: development
    expose:
    - '3000'
    image: roloch4/server-staging:latest
    networks:
      app-network: {}
    ports:
    - 3000:3000/tcp
    restart: always
version: '3.0'
volumes:
  dbdata: {}
  node_modules_c: {}
  node_modules_s: {}

Steps to reproduce the issue

  1. Create a remote context connecting to an EC2 instance via SSH using docker context create
  2. Switch to that context using docker context use <context-name>
  3. Try to deploy the local docker-compose app to the remote context using docker-compose up

Observed result

Error message above

Expected result

No error message, starts up the docker-compose services in remote machine

Stacktrace / full error message

Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 72, in main
  File "compose/cli/main.py", line 125, in perform_command
  File "compose/cli/command.py", line 54, in project_from_options
  File "compose/cli/docker_client.py", line 41, in load_context
  File "site-packages/docker/context/api.py", line 97, in get_context
  File "site-packages/docker/context/context.py", line 61, in load_context
  File "site-packages/docker/context/context.py", line 87, in _load_meta
KeyError: 'StackOrchestrator'
[92007] Failed to execute script docker-compose
make: *** [stageup] Error 255

Additional information

Running macOS Catalina 10.15.4

Installed docker-compose v1.2.6-rc3 on both local machine and EC2 instance using

curl -L https://github.com/docker/compose/releases/download/1.26.0-rc3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 25
  • Comments: 25

Most upvoted comments

I wasnt running docker-desktop 🤦

_Please like this erore to install _ MTProxy On ubuntu 16 04 ⇩⇩

`Traceback (most recent call last): File “urllib3/connectionpool.py”, line 677, in urlopen File “urllib3/connectionpool.py”, line 392, in _make_request File “http/client.py”, line 1252, in request File “http/client.py”, line 1298, in _send_request File “http/client.py”, line 1247, in endheaders File “http/client.py”, line 1026, in _send_output File “http/client.py”, line 966, in send File “docker/transport/unixconn.py”, line 43, in connect FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “requests/adapters.py”, line 449, in send File “urllib3/connectionpool.py”, line 727, in urlopen File “urllib3/util/retry.py”, line 403, in increment File “urllib3/packages/six.py”, line 734, in reraise File “urllib3/connectionpool.py”, line 677, in urlopen File “urllib3/connectionpool.py”, line 392, in _make_request File “http/client.py”, line 1252, in request File “http/client.py”, line 1298, in _send_request File “http/client.py”, line 1247, in endheaders File “http/client.py”, line 1026, in _send_output File “http/client.py”, line 966, in send File “docker/transport/unixconn.py”, line 43, in connect urllib3.exceptions.ProtocolError: (‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “docker/api/client.py”, line 205, in _retrieve_server_version File “docker/api/daemon.py”, line 181, in version File “docker/utils/decorators.py”, line 46, in inner File “docker/api/client.py”, line 228, in _get File “requests/sessions.py”, line 543, in get File “requests/sessions.py”, line 530, in request File “requests/sessions.py”, line 643, in send File “requests/adapters.py”, line 498, in send requests.exceptions.ConnectionError: (‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “bin/docker-compose”, line 3, in <module> File “compose/cli/main.py”, line 67, in main File “compose/cli/main.py”, line 123, in perform_command File “compose/cli/command.py”, line 69, in project_from_options File “compose/cli/command.py”, line 132, in get_project File “compose/cli/docker_client.py”, line 43, in get_client File “compose/cli/docker_client.py”, line 170, in docker_client File “docker/api/client.py”, line 188, in init File “docker/api/client.py”, line 213, in _retrieve_server_version docker.errors.DockerException: Error while fetching server API version: (‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’)) [27334] Failed to execute script docker-compose omega@ADAKServer-fsn1-1239:~/docker-compose-mtproxy$`

** Please Help Me… ** 🙂🤘

I was able to fix this issue by adding the parameter --default-stack-orchestrator swarm when creating the context:

docker context create NAME --description "DESCRIPTION" --docker "host=ssh://user@example" --default-stack-orchestrator swarm

After that, I had the issue that compose could not access my encrypted SSH private key. I just decrypted it for now…

Worked for:

  • docker compose: 1.26.0-rc3, build 46118bc5
  • docker ce: 19.03.8

I got a similar error but I found the reason is I didn’t open Docker Desktop (I am running on a windows 10 command line) like @maniankara

logs_93.zip Verbose logs attached. (docker-compose --verbose up) Also happens with compose 26.0.

adding ssh context user to docker’s group worked for me

on ssh host: sudo usermod -aG docker $USER

https://docs.docker.com/engine/install/linux-postinstall/