Vad1mo
Vad1mo

Reputation: 5543

docker running a data container from scratch

I created a data only container containing static HTML files that are intended to be consumed by a nginx container. Goal is that my webapp is providing a volume that nginx can use.

For this reason I created a simple Dockerfile:

FROM scratch
MAINTAINER me <[email protected]>
ADD dist/ /webappp/

When I run the created container from command line run -d -v /webappp --name webapp myOrg/webapp echo yo

I get the error Error response from daemon: Cannot start container db7fd5cd40d76311f8776b1710b4fe6d66284fe75253a806e281cd8ae5169637: exec: "echo": executable file not found in $PATH which if of course correct because the image has no commands at all the can be executed. Running a container without a command is not possible.

While this error on command line is not a big problem for me because I know the data container is still created and can now be accessed by nginx it turns out to be a no go if I want to automate it with Vagrant. The automated processes always fail because of this error.

My only solution so far is to extend my little handy image from from a distro which IMHO doesn't make sense for a data only container in order just to call echo or true!

Is there a NOP exec command in docker or does docker need always to execute something, is it possible to run a scratch container that does nothing or does not produce an error.

Upvotes: 7

Views: 4177

Answers (2)

Vad1mo
Vad1mo

Reputation: 5543

As mentioned in the Docker manual: The container don't need to be running. It also doesn't say that the container "should" be able to run at all.

So instead of echoing something stupid by running a data only container e.g. docker run -v /webappp --name webapp myOrg/webapp echo yo

It is already enough to just create the container and never run/start it.

docker create -v /webappp --name webapp myOrg/webapp

Note to self: Vagrant does not support docker create when provisioning!

Upvotes: 7

Adrian Mouat
Adrian Mouat

Reputation: 46500

Why are you using scratch?

Just use the nginx image as a base. You already have the image cached so it won't take up any more space and you'll be able to call echo.

Some references for data containers:

Upvotes: 4

Related Questions