Yes, I edited Dockerfile. I’ve tried many variations.
COPY ./app /code/app/
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"]
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 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.
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
This is a minimal Dockerfile that reproduces the error:
RUN touch /a.txt
I have tried, without success:
Changing the base image (tried ubuntu, debianpython: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 download.docker.com 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.