Home > front end >  Dockerfile entrypoint/cmd not executing on container import
Dockerfile entrypoint/cmd not executing on container import

Time:03-30

I'm trying to export a container, import it and then run it. But, the CMD/ENTRYPOINT in dockerfile is not executing on the imported container.

How do I execute the same commands specified in Dockerfile when the image was built? I know that it can be specified with docker run image <cmd> but, how is the CMD/ENTRYPOINT lost in the export/import process? And, is there a better way for importing/exporting containers?

Here is the dockerfile:

FROM python:3-alpine

WORKDIR app

ADD ./app.py .
ADD ./requirements.txt .
RUN pip3 install -r requirements.txt

CMD ["python3", "app.py"]

And the commands run in succession:

docker build . -t python-app
docker run --name app-container python-app    
docker export app-container > app-container.tar  
docker import app-container.tar "import-container:latest"  
docker run --name import import-container:latest    
# docker: Error response from daemon: No command specified.

CodePudding user response:

docker export exports the filesystem of a container, not an image. That's why the CMD and ENTRYPOINT aren't exported.

If you want to make a tar file from an image, you should use docker save and docker load rather than docker export and docker import.

  • Related