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?

  • Update the limitation of memory/CPU for existing container in docker
  • /bin/sh: 1: ./configure: not found - dockerfile
  • standard_init_linux.go:178: exec user process caused “no such file or directory”
  • Laravel installed on a local volume (Mac) from docker nginx/php-fpm can't write session files
  • update git version in docker container
  • Building Apache Mesos cluster with Docker Compose
  • LetsEncrypt-ACMESharp http-01 challenge on IIS invalid
  • Migrating Established TCP connection with docker containers
  • Share folder from docker container to host
  • APScheduler running a Python Script
  • Docker-compose error when try to start
  • Start Docker with SSL
  • 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.