Home > Mobile >  Is Docker volumes content actually copied from host to container or not?
Is Docker volumes content actually copied from host to container or not?

Time:11-11

When I do something like this in docker compose:

  volumes:
    - ./host_config:/container_config

does Docker actually copy the content of host_config to the container folder container_config (meaning that the storage used size on the machine is actually increased by the size of the shared folder) or just "link" files?

I'm asking this because in my case host_config is like 100GB and I would not want the content of it to be really copied to the container (I know that the volumes are stored in /var/lib/docker/volumes so I dont want that folder to have additional 100GB on my machine).

I've read https://docs.docker.com/storage/ but it's still not clear to me that part I'm asking, could anyone please better explain that to me?

Thanks

CodePudding user response:

does Docker actually copy the content of host_config to the container folder container_config

No.

or just "link" files?

No.

could anyone please better explain that to me?

Research "mount bind". This is exactly what docker actually does. https://unix.stackexchange.com/questions/198590/what-is-a-bind-mount https://docs.docker.com/storage/bind-mounts/

  • Related