How to mount to lowerdir (overlayfs)

215 Views Asked by At

I need to include some PHP code in the docker image and at the same time use some code from host directory while maintaining a certain file structure inside the running container.

How to write mount of hostdir1 in docker-compose.yml file correctly?

Let me explain with a short example:

  1. inside image (after build):
tree /mount
mount/
├── 1.txt
├── 4.txt
└── 5.txt
 cat mount/1.txt 
 internal
  1. on the host filesystem:
hostdir1/
├── 1.txt
├── 2.txt
└── somedir
    └── 3.txt
 cat hostdir1/1.txt
 external
  1. I need to mount host folder to contaider using smth like overlayFS and get the following file structure in the running container:
mount/
├── 1.txt
├── 2.txt
├── 4.txt
├── 5.txt
└── somedir
    └── 3.txt
cat mount/1.txt 
internal

Upd: Here They simply mount the directory into the container, overwriting all the contents of the directory in the image. I need to mount the host directory from below to the desired image directory. Keeping available all the files that are in the image and adding to them those files and directories that are on the server but are not in the image.

0

There are 0 best solutions below