0

Let's say I have a directory /var/www/html inside the container. I want to view it's contents outside in let's say ~/my_user/sites ( folder sites is not yet created ). I know I can use the volume mapping in docker-compose as follows-

volumes:
  - ~/my_user/sites:/var/www/html

But whenever I do this, the directory /var/www/html inside the container is mounted to an empty directory, therefore itself become empty. I know that this is how mounting is supposed to work but isn't there a way by which I can get access to the contents of the container in the host directory structure itself.

Also, if you have an easy workaround this then please mention that.

Divyasheel
  • 15
  • 4
  • I'd recommend checking out the original source tree from source control. You can't directly mount a container's files to the host or directly edit the files, and in any case changes you make inside a container will be lost as soon as the container exits. That is: any sort of volume mount _always_ hides the content that was originally present in the image. – David Maze Feb 06 '22 at 17:23
  • The "Mount directory in Container" question I linked to describes the sorts of changes you'd need to make in the image to replicate its files to a mounted volume. However, if you can do this, you probably already have the original source files. – David Maze Feb 06 '22 at 17:25

0 Answers0