A
A
astaxov812020-10-25 19:42:34
Docker
astaxov81, 2020-10-25 19:42:34

How to set permissions on VOLUMES in docker?

Hello.

I decided to deal with Docker, I can’t solve one problem, logs with root rights are written to the logs directory. Project structure:
- hosts/
- images/
- php/
- logs/
- mysql/
- www/
- default.test/
docker-compose.yml

docker-compose.yml

version: '3'
services:
  nginx:
    image: nginx:latest
    ports:
      - "8000:80"
    volumes:
      - "./hosts:/etc/nginx/conf.d"
      - "./www:/var/www"
      - "./logs:/var/log/nginx"
    links:
      - "php"
  php:
    build: "./images/php"
    volumes:
      - "./www:/var/www"


I tried to add to nginx:
user: "1000:1000" (id and group of the current user). But with such manipulations, the service does not start, in the logs there is a lot of swearing with "permission denied".

I also found this solution to the problem, forward it to the container:
- "/etc/passwd:/etc/passwd"
- "/etc/groups:/etc/groups"

It didn't help either :((

Is it possible to make the logs from nginx were created under the rights of the current user and if you need to delete them, you did not have to go into the console every time with the command sudo rm *.log.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question