New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Container doesn't have the expected behaviour after using commit --change
#29502
Comments
That's expected with the commands you're using; the "working" image uses the "exec form" (JSON) notation, therefore does not use the default If you change your $ docker build -t tini:ko .
...
$ docker inspect -f "{{ json .Config.Cmd }}" tini:ko
["top"]
$ docker inspect -f "{{ json .Config.Entrypoint }}" tini:ko
null Using exec-form notation; $ docker rm -fv container-top
container-top
$ docker run -d --name container-top tini:ko
636e8b46f5fa354e202df817f365cd3d73e030b375a16644ba67d6e05acf040a
$ docker commit -c 'ENTRYPOINT ["tini", "--"]' -c 'CMD ["top"]' container-top
sha256:2e26d803d88f6fc46acd7632fa20a832b2962054bc1ec3e67a20b7b6e3b58a21
$ docker inspect -f "{{ json .Config.Cmd }}" 2e26d803d88f6fc46acd7632fa20a832b2962054bc1ec3e67a20b7b6e3b58a21
["top"]
$ docker inspect -f "{{ json .Config.Entrypoint }}" 2e26d803d88f6fc46acd7632fa20a832b2962054bc1ec3e67a20b7b6e3b58a21
["tini","--"]
$ docker run -it --rm 2e26d803d88f6fc46acd7632fa20a832b2962054bc1ec3e67a20b7b6e3b58a21
top - 18:44:06 up 4:18, 0 users, load average: 0.03, 0.02, 0.00
Tasks: 2 total, 1 running, 1 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.2 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.2 st
KiB Mem: 8175164 total, 1321532 used, 6853632 free, 35192 buffers
KiB Swap: 0 total, 0 used, 0 free. 1063944 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 4224 652 576 S 0.0 0.0 0:00.03 tini
7 root 20 0 21920 2408 2084 R 0.0 0.0 0:00.00 top New Note that Docker 1.13 has a new For example, using the same $ docker run --init -it --rm tini:ko
Tasks: 2 total, 1 running, 1 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.2 us, 0.0 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 8175164 total, 1320436 used, 6854728 free, 35648 buffers
KiB Swap: 0 total, 0 used, 0 free. 1063976 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 1144 4 0 S 0.0 0.0 0:00.04 init
7 root 20 0 21920 2408 2080 R 0.0 0.0 0:00.00 top As you can see, I'll close this issue, because this is not a bug, but I hope this is useful to you. |
Thanks @thaJeztah for the explanation and for the 1.13 sneak peek! I haven't noticed the exec form in the command. Now
I would expect If I use a |
@jfusterm no, I don't think it's possible. Docker build makes sure these are evaluated but docker commit does not take these steps; https://github.com/docker/docker/blob/ca6c6f0765aeccdb2730d03c05bd965906df8cd4/daemon/commit.go#L44 Is there a reason you're not using a Dockerfile? |
Got it. I was just testing new Packer's functionality to add instructions like |
Feel free to open a separate issue for that though |
Description
Recently Packer has released the version
0.12.1
with support for the Docker builder to introduce changes viacommit --change
.I have tested that functionality and the resulting containers doesn't work as expected. All the containers I have built with Packer uses
tini
asENTRYPOINT
, and the problem is thatcommit --change
appends/bin/sh -c
to both theENTRYPOINT
and theCMD
, gettingsh
PID 1 instead oftini
.Steps to reproduce the issue:
Build the image from that
Dockerfile
.Both
CMD
andENTRYPOINT
are defined and the container works as expected, havingtini
PID 1.commit
Build the image without
ENTRYPOINT
.The resulting image doesn't have
ENTRYPOINT
but works as expected withouttini
.Now using
commit --change
, append theENTRYPOINT
and theCMD
instruction.After launching the container from the new image it doesn't start. Putting just the
ENTRYPOINT
with the command on it works, but not as expected.tini
doesn't have PID 1 but 5.Describe the results you received:
If the image has been built using a
Dockerfile
, works as expected but if the image has been modified withcommit --change
the behaviour is different.Describe the results you expected:
I would expect to start
tini
as PID 1 either building the image usingDockerfile
or withcommit --change
. The problem is the appended/bin/sh -c
.Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.):
Using Docker for Mac.
The text was updated successfully, but these errors were encountered: