5

I have an origin docker image, I want to ran a container and modify it, then commit a new image. I inspect the original docker image, and it has a conf

"Config": {
        ...
        "Cmd": [
            "/bin/bash",
            "-ic",
            "./run.sh"
        ],

         ...,
        "Entrypoint": null,
        ...
    },

I want to keep the same Cmd and Entrypoint for the new committed image. But no matter I use --change or not, I cannot keep the "Entrypoint": null for the new image. Is there any way to do so? Moreover, I also use docker-py, it has the same problem.

LetsOMG
  • 429
  • 1
  • 5
  • 11

2 Answers2

6

Considering issue 23498 and PR 23498, try using:

--change '[""]'
# or
--change []

If the array consists of exactly one empty string ([""]) then the entry point is reset to system default (i.e., the entry point used by docker when there is no ENTRYPOINT instruction in the Dockerfile).

However, if the system default is /bin/sh -c... that would not work for you.
See "Default Docker entrypoint".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

You should write down the specific changes you made in a Dockerfile. It can be as little as

FROM the-base-image
RUN ...

docker build will preserve the ENTRYPOINT and CMD from the base image.

If the base image updates, you can re-run docker build and get a new derived image; when something breaks in your image six months from now, you'll have a record of what went into it so that you can build it again. (That is, I'd suggest never using docker commit at all.)

David Maze
  • 130,717
  • 29
  • 175
  • 215