How could I get files from a docker container running the official etcd image if there is no shell?
I have a docker container that is running the etcd docker image by CoreOS which can be found here: https://quay.io/repository/coreos/etcd. What I want to do is copy all the files that are saved in etcd’s data directory locally. I tried to connect to the container using
docker exec -it etcd /bin/sh but it seems like there is no shell (
/bin/sh) on there or at least it can’t be found on the
$PATH variable. How can I either get onto the image or get all the data files inside of etcd copied locally?
2 Solutions collect form web for “How could I get files from a docker container running the official etcd image if there is no shell?”
You can export the contents of an image easily:
docker export <CONTAINER ID> > /some_file.tar
Ideally you should use volumes so that all your data is stored outside the container. Then you can access those files like any other file.
Docker has the cp command for copying files between container and host:
docker cp <id>:/container/source /host/destination
You specify the container ID or name in the source, and you can flip the command round to copy from your host into the container:
docker cp /host/source <id>:/container/destination