Reputation: 5539
Is it possible to create an image of the contents of a folder on host. And later extract the content from image to the machine? If so how?
Here is my failed attempt:
Dockerfile
WORKDIR '/data'
COPY ./hostfolder .
Command executed:
docker build -t mydata .
Folder structure:
Error:
Sending build context to Docker daemon 3.584kB
Error response from daemon: No build stage in current context
Upvotes: 1
Views: 894
Reputation: 14776
Yes, you can use a docker image as a place to store and then extract files.
First, you are missing a FROM
directive in your Dockerfile
. This is the reason for your error:
FROM alpine
WORKDIR '/data'
COPY . .
Then, to build the image:
$ docker build -t temp .
Then, to extract files, start the container:
$ docker run --detach --name data temp
and copy from the container to the host:
$ docker cp data:/data ./result
Upvotes: 2