55

I am trying to take a docker container from one machine and run it on another and encountering this error: "Error response from daemon: No command specified".

Below is a simplified example showing the problem:

docker --version
Docker version 1.10.1, build 9e83765
docker pull ubuntu
docker run --name u1 -dit ubuntu:latest
docker export -o exported u1
docker stop u1
docker rm u1
docker import exported ubuntu:imported
docker run --name u1 -dit ubuntu:imported
docker: Error response from daemon: No command specified.

In that example, we first pull an image (ubuntu) and successfully create/run container u1 from it. Then we export that container to a file (exported), stop/remove the container, import the file into a new image (ubuntu:imported) and try to run a new container from it. It fails.

0

6 Answers 6

39

docker export does not export everything about the container — just the filesystem. So, when importing the dump back into a new docker image, additional flags need to be specified to recreate the context.

For example, if the original container was running fine because the Dockerfile that was used for creating its image had CMD ["/usr/bin/supervisord"] in it, then import your dump this way:

docker import \
--change 'CMD ["/usr/bin/supervisord"]' \
path/to/dump.tar imagename:tagname
4
  • 7
    You can run docker inspect imagename:tagname comparing the original and that imported. I had no luck with import/export and --change, though everything works fine with save/load.
    – earcam
    Mar 18, 2019 at 2:50
  • Thank you, I have the same problem and I wonder which command should I use? because the command you have mentioned fails for me. Is there a general command?
    – Bionix1441
    Oct 29, 2020 at 9:56
  • @Bionix1441 You should probably use the one from the Dockerfile or the command used in the container from which you exported. Under Powershell : docker container inspect <container> | ConvertFrom-Json | Select -expand Config | Select Cmd. Under Bash (probably sthg like) : docker container inspect <container> | jq ".Config.Cmd".
    – nvidot
    Jan 10, 2021 at 20:59
  • 1
    Holy cow. Why is there no way to move a container from one host to another without a million ifs, ands, or buts, half of which directly contradict the other half, and none of which work? When save/load didn't work as promised, and googling for errors finally revealed that save/load doesn't copy everything and to use export/import, that didn't work, because, apparently, now, export/import doesn't save the entire container and I need to use save/load for that? Who designed this torture, Franz Kafka? George Orwell? A week on this now and still no working answer anywhere on the internet.
    – John Smith
    Nov 9 at 3:51
33

you can use docker load command to load images from archive file . this command will import image file and args together.

4
  • 2
    What is "archive" file in this case and how to create it?
    – Greendrake
    May 17, 2018 at 3:33
  • 12
    @Greendrake docker load and docker save operate on container images (from which containers are created), while docker import and docker export operate on containers. May 17, 2018 at 4:23
  • docker save and docker load do indeed operate on images. But if docker export operates on containers it is not the case of docker import which operates on images! In fact the real commands are docker image save ..., docker image load ..., docker container export ... and docker image import .... However, both archive types are not interchangeable! load operates on the archives produced by save. import operates on the archives produced by export.
    – nvidot
    Jan 10, 2021 at 16:42
  • I had a zip file archive in my case, in this situation the following worked well: $ cat file-name.zip | docker load Aug 27 at 21:44
2

Got this error when trying to export and import docker microsoft/mssql-server-linux.

https://hub.docker.com/r/microsoft/mssql-server-linux/

Commands to export and import:

docker export --output "C:\Users\oscar\Desktop\sqlTestMS.tar" msSQL

docker import "C:\Users\oscar\Desktop\sqlTestMS.tar" mssql

However we could not find the command to run it. The solution was listing all containers on the exporting machine and looking at the command ran.

docker ps

enter image description here

From there we could find out how to run the correct command:

docker run --name msSQL -p 1401:1433 -d mssql:latest /opt/mssql/bin/sqlservr
1

When you export a container it lost own history which contains image layers and meta data. So your container lost its pid states.

Every container should have a initial (root) process. You are overiding the default entrypoint on the dockerfile as bash. [edited] I think even you dont override it uses default , not defined in ubuntu base image. So you should start your initial process with cmd command. I think there is no bug. It is a dockerfile feature for reusablity.

2
  • I am overriding the entrypoint in the workaround to the original problem only. Nothing is overridden during export/import.
    – Greendrake
    Apr 12, 2016 at 8:04
  • hi @DrakeES my answer just updated. I explainee what happen when you export a container.
    – pmoksuz
    Apr 12, 2016 at 9:47
1

Got it working with these additional steps:

  1. Create Dockerfile as follows:

    FROM ubuntu:imported
    ENTRYPOINT ["/bin/bash"]
    
  2. Build new image:

    docker build -t ubuntu:importedwithdockerfile .
    
  3. Now it will run:

    docker run --name u1 -dit ubuntu:importedwithdockerfile
    

However, it is still unclear why simply exported and then imported image does not work right away. Is this a bug?

0

if using import

docker save nginx:alpine | ssh rmeote-host docker import -
sha256:f6098fc18511abbbfe9e52ed0d0ccc1fbe4f7b018ee1cd85392999aa92ebba1b

# we see errors
docker container run -d -p 2020:80  nginx:alpine
docker: Error response from daemon: No command specified.
See 'docker run --help'.

if using load

docker save nginx:alpine | ssh remote-host "cat - | docker load"
Loaded image: nginx:alpine

docker container run --name nginx -dp 2020:80 nginx:alpine
7cc8836bef1e276f8aa986a09186e9e227542be3b094b082b9ab1f6d3c290a99
docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS        PORTS                                   NAMES
7cc8836bef1e   nginx:alpine   "/docker-entrypoint.…"   2 seconds ago   Up 1 second   0.0.0.0:2020->80/tcp, :::2020->80/tcp   nginx

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .