I would like to create image including initial data. That is no problem. But I want to share those data (binary files) with another container and/or get those data out of the container to my local PC.
When I use volume, it will replace the folder inside container with empty one. I can mount folder "into" container but I need oposite direction – folder inside container to be visible out of docker.
Is there any option how to get data from container, other than docker cp
?
2
Answers
Not in the sense you are asking. You can share a volume or a mount between containers.
docker save
it and unpack.Start the container with just a
tar
command that streams the data out.STart a temporary contianers with
sleep infinity
, and like you suggested use docker cp.If its just a one time or not so frequent thing, you can copy the container data into the host machine through
docker cp
, and then create another container and use docker volume the next time to mount the host folder into the new container, in this case you will not have an empty folder, rather the data will be there