내 Dockerfile은 디렉터리를 생성하고 그 디렉터리를 선택한 다음 나중에 디렉터리를 나열합니다. 디렉토리는 여전히 루트 소유입니다. 왜 그런 겁니까?
다음은 Dockerfile입니다.
FROM ubuntu:precise
RUN useradd -d /home/testuser -m -s /bin/bash testuser
RUN mkdir -p /var/local/testrunner/logs
VOLUME ["/var/local/testrunner/logs"]
RUN grep testuser /etc/passwd
RUN grep root /etc/passwd
RUN chown -R testuser:testuser /var/local/testrunner/logs
RUN ls -ld /var/local/testrunner/logs
다음은 "docker build"의 출력입니다.
Sending build context to Docker daemon 10.24 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu:precise
---> ab8e2728644c
Step 1 : RUN useradd -d /home/testuser -m -s /bin/bash testuser
---> Using cache
---> 640f12671c86
Step 2 : RUN mkdir -p /var/local/testrunner/logs
---> Using cache
---> bf7756fd5b1f
Step 3 : VOLUME ["/var/local/testrunner/logs"]
---> Using cache
---> 65c73ee76c20
Step 4 : RUN grep testuser /etc/passwd
---> Using cache
---> db72fff0b965
Step 5 : RUN grep root /etc/passwd
---> Running in ebff78df7a9a
root:x:0:0:root:/root:/bin/bash
---> ead0ff704a59
Removing intermediate container ebff78df7a9a
Step 6 : RUN chown -R testuser:testuser /var/local/testrunner/logs
---> Running in c925f67b2ab4
---> 253132be935e
Removing intermediate container c925f67b2ab4
Step 7 : RUN ls -ld /var/local/testrunner/logs
---> Running in 978bc66aa47e
drwxr-xr-x 2 root staff 4096 Oct 1 15:15 /var/local/testrunner/logs
Docker 버전 1.2.0, 빌드 fa7b24f
호스트는 Ubuntu 12.04를 실행하지만 3.13.0-36 일반 커널을 사용합니다.