Docker mount a volume as root
Asked Answered
M

0

2

The problem description

I have a Docker image, which is being executed with volume mounting options a large number of times. It is built in a way so that the default user does not have root permissions. However I need to make sure that when I mount the volume it is being mounted as root and not as the current working user because of security concerns. (The current working non-root user must not be allowed to delete any files inside the mounted volume.)

Example

From the host machine:

docker run -it -v /path/to/mount:/container/mounting/path image-name

Inside the container current-user@docker-container:

All of the files inside /container/mounting/path must have owner permissions root root and not current-user current-user.

Mou answered 19/8, 2015 at 13:50 Comment(1)
You may run into container privilege issues, in which case you can either add the right capability or use docker run -privilegedPolyhistor

© 2022 - 2024 — McMap. All rights reserved.