Tag Archives: docker: Error response from daemon: No command specified.

Docker: import container snapshot, execute and report an error: docker: error response from daemon: no command specified

Explain the function of static keyword and final keyword in Java in detail>>>

Problem phenomenon:

Export container snapshot through docker export:

1 docker export nginxDockerfileCopy > nginxDockerfileCopy.tar

View under current operation path: generated:

Then, the exported compressed package is imported as an image through docker import

1 cat exportContainerSnapshot/nginxDockerfileCopy.tar | docker import - username/nginx-importsnapshot

The query shows that the image has been generated

Next, docker run runs the image generation container

1 docker run --name testImportSnapshot -p 8084:80 -d username/nginx-importsnapshot

Error:

Solution:————————

According to the prompt, you need to specify the command. So, try adding the command after docker run:

1 docker run --name nginxDockerfileCopy -p 8093:80 -d username/nginx-dockerfilecopy /bin/bash

The execution is successful and no error is reported. However, access to nginx is not available

Query the status of the container and find that it has stopped. Although the – D background execution parameter is added in the execution, it stops automatically. It seems that the/bin/bash command is not enough to start nginx

Because this is a snapshot exported from the container “nginxdockerfilecopy”, I checked the command parameter of “nginxdockerfilecopy”:

Refer to the above command and change the run command to:

docker run --name testImportSnapshot -p 8094:80 -d username/nginx-importsnapshot nginx -g 'daemon off;'

At this point, view the container status:

The container is in the start state

Browser access: http://localhost : 8094/index.html to see the nginx page

Visit: http://localhost : 8094/haha.html this is the existing accessible page when exporting from the container “nginxdockerfilecopy”. It can also be accessed normally

It shows that the container snapshot is exported and imported to generate a new image, and the new image is executed to generate a container. The container has the same function as before export