docker icon indicating copy to clipboard operation
docker copied to clipboard

getting permissions error with docker

Open ralyodio opened this issue 5 years ago • 3 comments

Matomo couldn't write to some directories (running as user 'www-data').

Try to Execute the following commands on your server, to allow Write access on these directories:

chown -R www-data:www-data /var/www/html
find /var/www/html/tmp -type f -exec chmod 644 {} \;
find /var/www/html/tmp -type d -exec chmod 755 {} \;
find /var/www/html/tmp/assets/ -type f -exec chmod 644 {} \;
find /var/www/html/tmp/assets/ -type d -exec chmod 755 {} \;
find /var/www/html/tmp/cache/ -type f -exec chmod 644 {} \;
find /var/www/html/tmp/cache/ -type d -exec chmod 755 {} \;
find /var/www/html/tmp/logs/ -type f -exec chmod 644 {} \;
find /var/www/html/tmp/logs/ -type d -exec chmod 755 {} \;
find /var/www/html/tmp/tcpdf/ -type f -exec chmod 644 {} \;
find /var/www/html/tmp/tcpdf/ -type d -exec chmod 755 {} \;
find /var/www/html/tmp/templates_c/ -type f -exec chmod 644 {} \;
find /var/www/html/tmp/templates_c/ -type d -exec chmod 755 {} \;
If this doesn't work, you can try to create the directories with your FTP software, and set the CHMOD to 0755 (or 0777 if 0755 is not enough). To do so with your FTP software, right click on the directories then click permissions.

DOcker should be running everything as root so I'm not sure why there are permission issues inside the container.

ralyodio avatar May 12 '20 00:05 ralyodio

I know what you mean, it surprises me that their example code (apache at least) is not working from the get go.

Here is what I recommend: Create a dockerfile like this:

FROM matomo:3.13

RUN chown -R www-data:www-data /var/www/html
RUN find /var/www/html/tmp -type f -exec chmod 644 {} \; || true
RUN find /var/www/html/tmp -type d -exec chmod 755 {} \; || true
RUN find /var/www/html/tmp/assets/ -type f -exec chmod 644 {} \; || true
RUN find /var/www/html/tmp/assets/ -type d -exec chmod 755 {} \; || true
RUN find /var/www/html/tmp/cache/ -type f -exec chmod 644 {} \; || true
RUN find /var/www/html/tmp/cache/ -type d -exec chmod 755 {} \; || true
RUN find /var/www/html/tmp/logs/ -type f -exec chmod 644 {} \; || true
RUN find /var/www/html/tmp/logs/ -type d -exec chmod 755 {} \; || true
RUN find /var/www/html/tmp/tcpdf/ -type f -exec chmod 644 {} \; || true
RUN find /var/www/html/tmp/tcpdf/ -type d -exec chmod 755 {} \; || true
RUN find /var/www/html/tmp/templates_c/ -type f -exec chmod 644 {} \; || true
RUN find /var/www/html/tmp/templates_c/ -type d -exec chmod 755 {} \; || true

You could probably remove most of these RUNs but they dont hurt so I just left them as is.

acountrec avatar Jun 11 '20 11:06 acountrec

above you hvae given basic image as matomo, what if I need PHP apache as base image, than how can i correct these tmp folder errors

bhavnapruthi823 avatar Dec 13 '20 21:12 bhavnapruthi823

I'm getting the same issue here with the latest image... image

docker-compose is as follows (using nginx proxy manager so only exposing port)

version: '3'
services:
  app:
    image: matomo:latest
    restart: unless-stopped
    environment:
      - MATOMO_DATABASE_HOST=db
      - MATOMO_DATABASE_TABLES_PREFIX=mat_
      - MATOMO_DATABASE_USERNAME=matomo-CHANGE
      - MATOMO_DATABASE_PASSWORD=matomo-CHANGE
      - MATOMO_DATABASE_DBNAME=matomo
    volumes:
      - /home/ediflyer/containers/matomo/app:/var/www/html
    links:
      - db:db
    expose:
      - 80/tcp
    networks:
      - nginx-proxy-manager_default         
  db:
    image: yobasystems/alpine-mariadb:latest
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: matomo
      MYSQL_USER: matomo-CHANGE
      MYSQL_PASSWORD: matomo-CHANGE
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - /home/ediflyer/containers/matomo/db:/var/lib/mysql
    networks:
      - nginx-proxy-manager_default
networks:
  nginx-proxy-manager_default:
    external: true
    name: nginx-proxy-manager_default

EDIT - OK so I removed all containers and existing files and recreated the stack & that seemed to do the trick.

EDIflyer avatar Jul 31 '22 15:07 EDIflyer