I have a container with code in it. This container runs on production server. How can I share folder with code in this container to my local machine? May be with Samba server and then mount (cifs) this folder with code on my machine? May be some examples...
1 Answer
Using
docker cp <containerId>:/file/path/within/container /host/path/target you could copy some data from the container. If the data in the container and on your machine need to be in sync constantly I suggest you use a data volume to share a directory from your server with the container. This directory can then be shared from the server to your local machine with any method (e.g. sshfs)
The docker documentation about Manage data in containers shows how to add a volume:
$ docker run -d -P --name web -v /webapp training/webapp python app.py The data from you severs training/webapp location will then be available in the docker container at /webapp.
2 Comments
edenisn
but folder /webapp will be on the server hdd, not in my pc hdd
Flurin
@edenisn yes. That's where you would for example use sshfs to mount the servers directory to your local pc. I recommend this way because then your local computer only needs to connect to the server. Connecting into the docker container would be more involved.