Docker: I'm not able to make working a volume binding at runtime

I’m executing my image in this way:

docker run -it --rm my_image -v ~/.ssh/id_rsa:/home/realtebo/.ssh/id_rsa:ro

So I expect that my private rsa key is copied at runtime when executing.

  • Communication between variable number of Docker containers
  • Elastic Beanstalk Docker container running Node application exits early
  • How does Dockerfile ADD command work?
  • Docker: base image
  • Rename a project by keeping containers
  • cant connect to docker daemon - eclipse che
  • This is the shell script I used as entrypoint

    ls -la ~/.ssh

    At runtime I got this

    total 12
    drwxr-xr-x 2 realtebo realtebo 4096 Jan 19 08:20 .
    drwxr-xr-x 3 realtebo realtebo 4096 Jan 19 08:37 ..
    -rw-r--r-- 1 realtebo realtebo  393 Jan 19 08:20 known_hosts

    So the working dir and the user are ok.

    note: known_hosts is created at build time

    Why cannot I get /home/realtebo/.ssh/id_rsa as I expect ?

    I do some debugging using docker inspect <container_name. I discovered that :

    "HostConfig": {
            "Binds": null,

    But what’s the problem?

  • Jacoco agent - no output
  • docker-machine create with digitalocean driver and Ubuntu 16.04 x64 fails
  • Disable ip v6 in docker container
  • Creating User In Docker Container
  • smtp sendmail in Dockerised Golang Web App in GAE doesn't work
  • How to run a Docker host inside a Docker container?
  • One Solution collect form web for “Docker: I'm not able to make working a volume binding at runtime”

    Solution: exchange -v flag and image_name.
    Image name must always be the last argument (followed by optional cmd to execute)

    So instead of

    docker run -it --rm my_image -v ~/.ssh/id_rsa:/home/realtebo/.ssh/id_rsa:ro

    I need to execute in this way:

    docker run -it --rm v ~/.ssh/id_rsa:/home/realtebo/.ssh/id_rsa:ro my_image
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.