I created Django project with Docker Compose:
Dockerfile
FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD . /code/
RUN pip install -r requirements.txt
WORKDIR /code/example
ENTRYPOINT ["python", "manage.py"]
docker-compose.yml
postgres:
image: postgres
ports:
- '5432:5432'
django-project:
build: .
command: runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- '8000:8000'
links:
- postgres
It work nice. But all new files which create through container 'django-project' have root owner and group.
I try add user: user
in Compose config for container django-project
.
But got exception User user not found
.
I try add user
in container with code:
ENV HOME_USER user
ENV HOME_PASS password
RUN useradd -m -s /bin/bash ${HOME_USER} && \
echo "${HOME_USER}:${HOME_PASS}"|chpasswd && \
adduser ${HOME_USER} sudo && \
echo ${HOME_USER}' ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
But exception stayed.
How I can apply non-root ownership for all new files which will create through docker container?