Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to export a file while inside a docker image?

Inside my docker image I am creating a FBX file. After the file is finished processing I want to export to my local machine. I want to do this from docker image.

like image 558
luii Avatar asked Jul 12 '17 21:07

luii


People also ask

Can you export a docker image?

Yes! Let the docker save image command and the docker export image command do the trick! In this tutorial, you'll learn how to save and export containers and images for sharing by running Docker commands.

How do I export a file from a container?

To export a container, we use the docker export command. The documentation describes export as follows: docker export – Export a container's filesystem as a tar archive. As we can see, this is just a regular old Linux file system — the BusyBox file system created when running our image, to be precise.

How we can export docker image locally?

The docker export - Export a container's filesystem as a tar archive. The docker import - Import the contents from a tarball to create a filesystem image. The docker save - Save one or more images to a tar archive (streamed to STDOUT by default) The docker load - Load an image from a tar archive or STDIN.


1 Answers

Run your container as this:

docker run -v $(PWD)/local-dir/:/path/to/results/dir (...rest of the command..)

So any file that is created inside the container into /path/to/results/dir gets automatically reflected in your host, inside ./local-dir.


Alternatively, you can copy any file from container to host:

docker cp <container-id>:/path/to/file ./local-dir
like image 106
Robert Avatar answered Nov 15 '22 05:11

Robert