The Docker documentation states that a CMD
or ENTRYPOINT
is required in order to successfully build an image, yet it is possible to build an image without either of these. The following example explains how to do this, using the Alpine tar as its base image:
FROM scratch
ADD alpine-minirootfs-3.11.2-x86_64.tar.gz /
COPY . /
To build the image, run:
docker build -t test:1 .
The image can then be run with no CMD
or ENTRYPOINT
:
docker run -ti test:1 /bin/sh
This demonstrates that it is possible to build a Docker image without either CMD
or ENTRYPOINT
.