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/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?

  • Docker $(pwd) and bash aliases
  • Setting up Ruby along with android in docker
  • Dockerfile vs Dockerrun.aws.json on AWS Elastic Beanstalk
  • Docker for Windows REST API - enable CROSS
  • Docker Strategy
  • Automount / NFS Problems with Rancher Network
  • MySQL in docker-compose — access denied
  • Unable to open application after docker-compose
  • CPU stats were not captured for docker containers
  • Kubernetes vs Kubernetes on Mesos? [closed]
  • Pulling docker images
  • Is it possible to run match servers on Kubernetes for a Real Time Multiplayer game?
  • 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
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.