Skip to content

Instantly share code, notes, and snippets.

@maietta
Created June 24, 2017 01:38
Show Gist options
  • Save maietta/f445c428665a1ba33bfbc40faa544dc6 to your computer and use it in GitHub Desktop.
Save maietta/f445c428665a1ba33bfbc40faa544dc6 to your computer and use it in GitHub Desktop.
If you need to do this on a running container you can use docker exec (added in 1.3).
First, find the container's name or ID:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b9b7400ddd8f ubuntu:latest "/bin/bash" 2 seconds ago Up 2 seconds elated_hodgkin
In the example above we can either use b9b7400ddd8f or elated_hodgkin.
If you wanted to copy everything in /tmp/somefiles on the host to /var/www in the container:
$ cd /tmp/somefiles
$ tar -cv * | docker exec -i elated_hodgkin tar x -C /var/www
We can then exec /bin/bash in the container and verify it worked:
$ docker exec -it elated_hodgkin /bin/bash
root@b9b7400ddd8f:/# ls /var/www
file1 file2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment