Reputation: 186
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/bash
, /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?
Upvotes: 0
Views: 387
Reputation: 11
the bin folder is empty. but the etcdctl
is in the /usr/local/bin/
folder.
so you can try:
docker exec -it <container_id> /usr/local/bin/etcdctl
docker exec -it <container_id> /usr/local/bin/etcdctl put foo "hello"
docker exec -it <container_id> /usr/local/bin/etcdctl get foo
Upvotes: 1
Reputation: 19194
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
Upvotes: 0
Reputation: 3447
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.
Upvotes: 1