3

I'm creating a volume like this:

docker volume create php

and want to mount a single file /etc/php.ini while running the container:

docker run -it -v php:/etc/php.ini image-name

This throws an error:

docker: Error response from daemon: readdirent: not a directory.
See 'docker run --help'.

Can I use volumes for this purpose or they are meant to handle directories only? What could be the solution here?

revo
  • 47,783
  • 14
  • 74
  • 117
  • 1
    I don't think it is off-topic actually because [`docker`](https://stackoverflow.com/questions/tagged/docker) tag seems to exist for such questions. – revo Feb 23 '19 at 13:52

1 Answers1

1

According to this answer:

when you create a named volume and run a service/container with docker run -v my_volume:/root/volume my_container, data is stored in /var/lib/docker/volumes/my_volume/_data

Following this affirmation, it is unpossible to create a named volume and mount it as a file inside a container.

gcharbon
  • 1,561
  • 12
  • 20