31
votes

I use mac 10.11.6 El capitan and i installed docker toolbox and i am trying to use docker compose build option but i am throwing some errors as follows,

kj$ docker-compose -f docker-compose-dev.yml build
Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 71, in main
  File "compose/cli/main.py", line 124, in perform_command
  File "compose/cli/command.py", line 41, in project_from_options
  File "compose/cli/command.py", line 113, in get_project
  File "compose/config/config.py", line 380, in load
  File "compose/config/config.py", line 380, in <listcomp>
  File "compose/config/config.py", line 513, in process_config_file
  File "compose/config/config.py", line 221, in get_service_dicts
  File "distutils/version.py", line 46, in __eq__
  File "distutils/version.py", line 337, in _cmp
TypeError: '<' not supported between instances of 'str' and 'int'
[83046] Failed to execute script docker-compose

The content of yml file

version: '3.3'

services:

  users:
    build:
      context: ./
      dockerfile: Dockerfile-dev
    volumes:
      - './:/usr/src/app'
    ports:
      - 5001:5000
    environment:
      - FLASK_APP=project/__init__.py
      - FLASK_ENV=development

I am not sure what causes this problem, Please give your suggestions, Thanks

13
What's inside your docker-compose-dev.yml file? It looks like it might be related to a Python module.alexdotsh
Remove the extra blank new lines in the yaml fileHernan Garcia
@Herman I dont have extra blankKSp

13 Answers

56
votes

The answer to this question is pretty straight forward, it happened to me this morning. When I finished working on my project I closed the docker app for Mac (mainly what the error says is that it cannot get the API version of Docker and or docker-compose). Make sure your Docker for desktop is running everything else should be back to normal.Check this image to see if docker desktop is running.

23
votes

I solved it by starting the docker service:

service docker start
3
votes

I was having the same problem as mentioned above:

[49326] Failed to execute script docker-compose

I am using Linux(ubuntu 20.04)

But the thing that I missed was that when I completed the docker install in the next steps it was mentioned as linuxpost-install steps. It clearly states that after the installation the docker always runs on the root. So until you have configured the non-root options on docker setting at this link should try using sudo before your command.

2
votes

In my side I have managed to resolve this by "Reset to factory defaults", i.e under docker preferences.

2
votes

Just make sure that the Docker app is opened on your machine

1
votes

It Worked for me in Windows:

Control Panel => Program and Features => Turn Windows Feature on or off => enable all the option for Hyper-V

enter image description here

1
votes

to anyone who's trying to do this with --context, add host user to docker's group

on ssh host: sudo usermod -aG docker $USER

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

0
votes

Just encountered this issue this morning on 10.14.6 (18G87) MacOS, which I just updated to this morning after everything was working perfectly yesterday.

Found out that one of my compose.yml files was using single quotes around the version when it should be double quotes. This fixed the issue for me. This is not a bug with Docker-compose.

0
votes

GM

The reason for this issue is, Docker (engine) services is stopped.

Remember that in Docker-Docs you have to read "Post-installation steps" to "Configure Docker to start on boot".

https://docs.docker.com/engine/install/linux-postinstall/#configure-docker-to-start-on-boot

ie. for Redhat/CentOs

$ sudo systemctl enable docker.service
$ sudo systemctl enable containerd.service

Regards.

0
votes

Restart the container resolved my issue.

0
votes

I am using WSL 2 and I had to do enable integration with the WSL distro I am using. It's in Settings > Resources > WSL Integration.

0
votes

I was trying tou lounch my back with the following command: docker-compose up --build

And I got this message:

docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied')) [5884] Failed to execute script docker-compose

All I had to do was to add "sudo" in front of the above mentioned command. sudo docker-compose up --build After this my back is launched :))

-4
votes

Change the version to be double quotes, it worked for me. version: "3.3"