Reputation: 6697
I have a server that a docker container is running on. I can see it by running docker container ls
:
And finding the image by running docker image ls
:
I also can open the container using this command docker exec -it <container_hash> sh
. All I need to do is making a zip file from the files of the project. I mean these files:
So, how can I copy/paste all files of a running container and make a zip file of them on the server? Noted that I use Ubuntu 20.04
Upvotes: 0
Views: 1239
Reputation: 1005
docker cp
is your friend here:
Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
Copy files/folders between a container and the local filesystem
Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.
Options:
-a, --archive Archive mode (copy all uid/gid information)
-L, --follow-link Always follow symbol link in SRC_PATH
So in your case you could use
docker cp <container_name>:/app /local/path/for/directory
This will copy the directory out to your local file system. From there you can use a utility to create an archive in whatever format you want.
Upvotes: 1