Reputation: 4090
I'm mounting files from my laptop's/host machine's working directory into the container, and I'm not sure why the mounted files are owned by www-data
. q
was created on the host machine, so it's owned by root
, as expected.
Inside container:
Some other observations:
Host UID (my OS X account): 1783256022 (not sure why it looks like this)
Container UID (www-data): 33
Dockerfile:
FROM nginx:1.13.8
RUN apt-get update
RUN apt-get install -y nano && \
apt-get install -y git && \
apt-get install -y procps && \
apt-get install net-tools
RUN mkdir -p /var/www/html
WORKDIR /var/www/html
docker-compose.yml:
version: '3'
services:
web:
build:
context: ./docker/nginx
image: tc-web:0.1.0
container_name: tc-web
volumes:
- ./:/var/www/html/
- ./docker/nginx/.bashrc:/root/.bashrc
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
ports:
- 8080:80
Upvotes: 1
Views: 746
Reputation: 13300
When you mount a directory using volumes in a Unix like system, files will keep the same permissions they have in the host in terms of uid a gid. That means that the uid that created the files in your host (your user probably) has the same user id of the www-data user inside the container.
When you create a file from inside the container, since the container is run as the root user, files will be owned by the root user (inside and outside the Container).
Upvotes: 2