bimka
(Bimka)
August 27, 2022, 5:56am
1
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
│ ├── __init__.py
│ ├── main.py
│ ├── services
│ └── static
├── traefik
│ └── traefik.toml
├── docker-compose.yaml
├── Dockerfile
└── requirements.txt
traefic.toml:
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web.http]
[entryPoints.web.http.redirections]
[entryPoints.web.http.redirections.entryPoint]
to = "websecure"
scheme = "https"
[entryPoints.websecure]
address = ":443"
[accessLog]
[providers]
[providers.docker]
exposedByDefault = false
[certificatesResolvers.letsencrypt.acme]
email = "mymail@mail.com"
storage= "acme.json"
[certificatesResolvers.letsencrypt.acme.httpChallenge]
entryPoint = "web"
docker-compose.yaml:
version: "3"
services:
app:
build: .
labels:
- traefik.enable=true
- traefik.http.routers.app-http.rule=Host(`mydomain.com`)
- traefik.http.routers.app-http.tls=true
- traefik.http.routers.app-http.tls.certresolver=letsencrypt
traefik:
image: traefik:v2.8
ports:
- 80:80
- 443:443
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- $PWD/testapp/traefik/traefik.toml:/etc/traefik/traefik.toml
- traefik-public-certificates:/certificates
volumes:
traefik-public-certificates:
Dockerfile:
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", "0.0.0.0", "--port", "8000"]
When deploying, it does not see the line:
CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "8000"]
How to fix the error “Error response from daemon: No command specified”?
rimelek
(Ákos Takács)
August 27, 2022, 1:26pm
2
Can you also show how you try to run and where you see the error message exactly?
bimka
(Bimka)
August 27, 2022, 2:04pm
3
The error occurs when executing the docker-compose up --build
command when I am in the testapp folder
rimelek
(Ákos Takács)
August 27, 2022, 2:16pm
4
You are using an other Dockerfile. Look at the steps during the build:
FROM
COPY
WORDKIR
RUN
RUN
COPY
RUN
and look at the instructions in the Dockerfile
FROM
COPY
WORKDIR
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?
bimka
(Bimka)
August 27, 2022, 2:46pm
5
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", "0.0.0.0", "--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", "0.0.0.0", "--port", "8000"]
in terminal
in this example I changes lines^
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
to
FROM python:3.9
rimelek
(Ákos Takács)
August 27, 2022, 3:04pm
6
Can you build the image without Docker Compose?
bimka
(Bimka)
August 27, 2022, 3:45pm
7
Yes, I can build image using
docker build -t myimage .
docker run -d --name mycontainer -p 80:80 myimage
and my app is deployind.
rimelek
(Ákos Takács)
August 27, 2022, 5:27pm
8
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
bimka
(Bimka)
August 27, 2022, 6:06pm
9
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(.
argon338
(Argon338)
October 10, 2022, 12:19pm
10
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.
argon338
(Argon338)
October 10, 2022, 3:20pm
11
SOLUTION: installed version 4.0.0 instead of latest