I'd like to build a docker image which will the base of my containers, but I'd like to prevent creating a container directly from it. Is it possible?
3 Answers
Every image (except scratch
, which is a special case) can be used to create a container, so no it's not possible.

- 141
- 4
As a possible workaround you may add
ENTRYPOINT false
to clearly state the you want anyone to run containers from it. Of course, it doesn't prevent container creation, but...

- 38
- 6
-
I didn't think so... It is perfect for me. – Sep 03 '20 at 08:48
You can't prevent creating a container from your images, but you can prevent the container from running anything. Simply don't include anything runnable in the container.
An example of a base image that does this is centurylink/ca-certs
(which is horribly out of date; don't use it for its intended purpose). It is based on scratch
and its only content is a CA certificate bundle file. It is not possible to run anything from this container as it contains no scripts or executables.

- 244,070
- 43
- 506
- 972