0

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 Answers3

2

Every image (except scratch, which is a special case) can be used to create a container, so no it's not possible.

Konrad Botor
  • 141
  • 4
1

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...

0

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.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972