57

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

3
  • What's inside your docker-compose-dev.yml file? It looks like it might be related to a Python module. Commented Mar 8, 2019 at 23:18
  • Remove the extra blank new lines in the yaml file Commented Mar 9, 2019 at 0:00
  • @Herman I dont have extra blank Commented Mar 9, 2019 at 7:29

18 Answers 18

98

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.

Sign up to request clarification or add additional context in comments.

Comments

39

I solved it by starting the docker service:

service docker start

1 Comment

This worked for me, just needed to: sudo service docker start. Is there no way to start it with the Docker add-on inside VSC?
9

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.

1 Comment

Ubuntu for me doing the docker java tutorial (docs.docker.com/language/java/build-images) in WSL. Restarting the shell worked for me. I had removed the images and other things on this board but didn't work. Neither did this 'sudo' suggestion thank goodness because it seems very scary.
6

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

1 Comment

Hi, you must specifiy more detail on this answer, like how to check this and why ?
4

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

2 Comments

This is not an answer to the original question. OP mentioned Mac OS, not Windows.
So do you think that we need to create a duplicate question with macOS replaced with windows?
2

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

Comments

2

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/

Comments

1

Upgrade to the latest script of docker-compose standalone:

https://docs.docker.com/compose/install/standalone/#on-linux

The other solutions doesn't work for me...

1 Comment

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
0

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.

Comments

0

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.

Comments

0

Restart the container resolved my issue.

Comments

0

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.

Comments

0

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 :))

Comments

0

Simply I checked General settings in Docker and enable Use Docker Compose V2 and actually it's work for me.

Comments

0

I had the same error and it solved by

sudo service docker start

Comments

0

Ensure your docker desktop is started appropriately. It is most likely not stated, I had similar error when I forgot to launch it

Comments

0

In my case, Docker is not up, So I have to launch Docker Desktop, start the Connection and run the command "docker-compose up" in command prompt.

Comments

-4

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

1 Comment

When I copied from version : "3.3" from a site, it didn't work. Double quotes was not interpreted in my machine. So, I deleted and typed " and it worked now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.