Docker works with a data container from scratch

I created a data container containing static HTML files that are intended to be used by the nginx container. The goal is that my webapp provides a volume that nginx can use.

For this reason, I created a simple Docker file:

FROM scratch MAINTAINER me < me@me.com > ADD dist/ /webappp/ 

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

I get an error message Error response from daemon: Cannot start container db7fd5cd40d76311f8776b1710b4fe6d66284fe75253a806e281cd8ae5169637: exec: "echo": executable file not found in $PATH , which, of course, is correct because the image does not have any commands at all. Starting a container without a command is not possible.

Although this error on the command line is not a big problem for me, because I know that the data container is still created and nginx is now available, it turns out that this is not the case if I want to automate it using Vagrant. Because of this error, automatic processes always fail.

My only solution so far is to extend my small handy image from the distribution, which IMHO does not make sense for a data-only container, just to cause an echo or true!

Is there a NOP exec command in docker or is it required that docker always do something, is it possible to start a container from scratch that does nothing or does not cause an error.

+6
source share
2 answers

As stated in the Docker manual: The container does not need to be started. Nor does he say that the container "should" be able to work at all.

So, instead of repeating something stupid, running only a container with data, for example. docker run -v /webappp --name webapp myOrg/webapp echo yo

Simply create a container and never start / run it.

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

Note for yourself: Vagrant does not support docker creation when configured!

+7
source

Why are you using a scraper?

Just use the nginx image as a base. You already have image caching, so it won’t take up more space and you can trigger an echo.

Some links for data containers:

+3
source

Source: https://habr.com/ru/post/980640/


All Articles