How to fix " Error response from daemon: No command specified"?

I’m beginer in Docker and I tryed to deploy my app with HTTPS powered by Traefik by this article.

I did everything according to the instructions for my project, but I got an error: “Error response from daemon: No command specified”.

How can I solve this issue?

app structure::

└── testapp
    ├── app
    │   ├──
    │   ├──
    │   ├── services
    │   └── static
    ├── traefik
    │   └── traefik.toml
    ├── docker-compose.yaml
    ├── Dockerfile
    └── requirements.txt


    address = ":80"
        to = "websecure"
        scheme = "https"

    address = ":443"


    exposedByDefault = false

  email = ""
  storage= "acme.json"
    entryPoint = "web"


version: "3"

    build: .
      - traefik.enable=true

    image: traefik:v2.8
      - 80:80
      - 443:443
    restart: always
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - $PWD/testapp/traefik/traefik.toml:/etc/traefik/traefik.toml
      - traefik-public-certificates:/certificates



FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
COPY ./app  /code/app/
WORKDIR ./code/
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir -r /code/requirements.txt
CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "", "--port", "8000"]

When deploying, it does not see the line:

CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "", "--port", "8000"]

How to fix the error “Error response from daemon: No command specified”?

Can you also show how you try to run and where you see the error message exactly?

The error occurs when executing the docker-compose up --build command when I am in the testapp folder

You are using an other Dockerfile. Look at the steps during the build:

  • FROM
  • COPY
  • RUN
  • RUN
  • COPY
  • RUN

and look at the instructions in the Dockerfile

  • FROM
  • COPY
  • COPY
  • RUN
  • CMD

Try to read the file from the terminal:

cat Dockerfile

Do you edit your files on a different machine and synchronize after that?

Yes, I edited Dockerfile. I’ve tried many variations.

Dockerfile now

FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
COPY ./app  /code/app/
WORKDIR ./code/
RUN cd /code/app/
RUN ls -lat
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir -r /code/requirements.txt
CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "", "--port", "8000"]

and Dockerfile before:

FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
COPY ./app  /code/app/
WORKDIR ./code/
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir -r /code/requirements.txt
CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "", "--port", "8000"]

in terminal

in this example I changes lines^

FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
FROM python:3.9

Can you build the image without Docker Compose?

Yes, I can build image using

docker build -t myimage .
docker run -d --name mycontainer -p 80:80 myimage

and my app is deployind.

What is the version of Docker Compose? It should work, but you can try to add some line breaks after the CMD instruction in your Dockerfile. Some apps can’t handle when the last line does not have a line break

I use Docker Compose version v2.10.2

I tryed to add some line breaks at the end of the Dockerfile, but it does not work(.

I have the same issue. Project was fine, and all works on my Mac, but later something went wrong without any changes in project.
Colleagues report on their computers (ubuntu) all works fine.
But mine docker compose at macOS with external docker context is not works.
It is hard to understand.

SOLUTION: installed version 4.0.0 instead of latest

Version 4.0.0 of what? I have encountered this same problem. Images were running fine and made no changes to Dockerfile using ENTRYPOINT. Suddenly can’t run any new images built “No command specified”.

Probably Docker Deskop, but that is old now so it won’t solve your problem. Since I have never had an error like that on any platform I still can’t imagine how it could be caused by Docker itself without changing the Dockerfile or at least rebuilding the image or changing the run command, unless there is a very old Docker used that I neved did. So you can make sure you are using the latest versions of Docker and if you can share your Dockefile and exact commands to reproduce the issue, we can try to help you. You don’t need to share the original Dockerfile, just a Dockerfile that gives you the same error.

If you have a Dockerfile and you rebuild the image, even if you didn’t change the Dockerfile but the base image changed, that can easily break your image.

Thanks for taking the time to respond. We found that the broken image was built by a different gitlab runner and going back to use the original gitlab runner fixed the problem, but other than that we are not sure what the underlying problem was.

Edit to add possible solution: disabling build kit by preppending build command with DOCKER_BUILDKIT=0

I am also experiencing this problem, recently. I am, indeed, using an older docker version

  Version:          19.03.8

This is a minimal Dockerfile that reproduces the error:

FROM ubuntu
RUN touch /a.txt
CMD ["bash"]

I have tried, without success:

  • Changing the base image (tried ubuntu, debian python:3.9 and tiangolo/uvicorn-gunicorn-fastapi:python3.9
  • Adding my own CMD at the end of the Dockerfile, or keeping the one from the base image
  • using both CMD syntaxes e.g. CMD bash or CMD ['bash']
  • adding an black line at the end
  • having a simplified run command docker run -it api

None of these seem to work.

What does seem to work is:

  • running my image by supplying the command during runntime docker run -it api bash
  • running an image from the dockerhub
    • docker run -it ubuntu gives me the bash prompt
    • docker run --rm -it tiangolo/uvicorn-gunicorn-fastapi:python3.9 launches a uvicorn server

From which I am guessing the issue is in the build step, that it is somehow ignoring both my Dockerfiles cmd and the base image.

The machine is running Ubuntu, with the docker system installed from the apt repos. All was working perfectly when I last tried to build an image of my own, some month or two ago.

Workaround / Solution?:

The one workaround that seems to work is to disable buildkit, this can be done by prepending the build command with DOCKER_BUILDKIT=0 docker build -t api . Alternatively, you can set the session wide env variable to achieve this.

This seems like a not-so-nice solution, but will have to do for now. Hope it helps others.

I will keep investigating, but any help would be appreciated.