I have pulled an image called php:5.6-apache, run it, touch a file in /var/www/html, then commit it.
Then I try to run the new image in detached mode:
# docker run --name test -d staraple/php:v1
But the container exited immediately after started.
IMAGE COMMAND CREATED STATUS staraple/php:v2 "apache2 -DFOREGROUN 4 seconds ago Exited (0) 3 seconds ago
Fisrt I though the new image lost the CMD after a commit action.
Refer to https://github.com/docker/docker/pull/4000 , CMD will reserved after commit;
My problem is why my container could not run in detached mode when I got a CMD. php.5.6-apache is official, and I just touch a blank file in it.
When I check json for images in /var/lib/docker/graph, I found my new image has a different Cmd config from the original one:
"Cmd":["/bin/sh","-c","#(nop) CMD [apache2 -DFOREGROUND]"] "Cmd":["apache2","-DFOREGROUND"]
docker logs show message:
https (pid 1) already running , other than
[core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND' .