I am trying to create a very simple image from scratch to simply provide a file. But Im not a bit skilled writing dockerfiles (on learning queue).
Id like to whenever the container starts, it copy the file from the container into the local host upon the mapped volume, nothing else. Im struggling to get accomplish it, I can build the image fine but I am unable to put the files into local box.
Dockerfile
FROM scratch
ADD datafile.dat /datafile.dat
ADD true /true
VOLUME ["/tmp/"]
COPY datafile.dat /tmp
CMD ["/true"]
'true' is nothing but an echo program. I am build it with
docker build -t datafile:latest -f Dockerfile .
Apparently, build goes fine. But when I try to run it I get nothing, and container exists with error.
$ docker run -dt -v /:/tmp datafile:latest
0a317b5d7459c86ff260513093d115f94be74671ebc08bc125d9e871a55695c5
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0a317b5d7459 datafile:latest "/true" 6 seconds ago Exited (1) 4 seconds ago laughing_keller
$ docker logs 0a3
standard_init_linux.go:195: exec user process caused "no such file or directory"
From building directory
$ ll
total 36
-rw-rw-r--. 1 vUser vUser 0 Aug 23 12:59 datafile.dat
-rw-rw-r--. 1 vUser vUser 126 Aug 23 13:06 Dockerfile
-rwxr-xr-x. 1 vUser vUser 28920 Aug 23 13:05 true