It might be helpful to create a container that has nothing. Nothing means nothing.
Use case
In this answer https://stackoverflow.com/a/55683656/1315009 a container is created without ever starting it just to instantiate a volume and copy contents into the volume. Then the container is removed.
The example instantiates a busybox
. Nevertheless the busybox
contents are never used. So I tested it with the hello-world
and it works as well, thus reducing from 1.22MB to 13.3kB.
At the time being, pulling "scratch" fails:
$ docker pull scratch
Using default tag: latest
Error response from daemon: 'scratch' is a reserved name
So... Question
How can I create a container with an image that has "nothing" inside?
I mean similar to docker create hello-world
but without the hello-world
binary.
Inspired on @BMitch's answer, the solution is that the
Dockerfile
can not only contain theFROM
sentence.It compiles, but fails when doing a
docker create
, the engine complains because it does not have a command even if it's a create and not a run.The complete Dockerfile is this one:
You can build it (in my case I named the image
xavi-scratch
) and then see the image is 0 bytes of data:I then create a container without running it:
There's a full session here testing it serves the purpose:
a
andb
and create one file ina
.b
is emptyb
.a
into the containerb
contains the file copied via the container.