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?

  • How to force docker for clean build of an image?
  • Docker swarm: How to manually set node names?
  • Docker service start failed
  • Docker: Map host ports to several docker containers
  • When will Docker be launched? [closed]
  • Assign static ip on docker 1.7
  • Serving local mapbox vector tiles from Windows using Docker
  • How can I pull the official images of IBM Container Service?
  • JRebel cache on Docker
  • Use GitLab CI to deploy app with ftp
  • yaml file error java_opts
  • docker: net: no such interface
  • 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.