HaschekSolutions / opentrashmail

Open Source standalone trashmail solution that ships its own mail server
Apache License 2.0
573 stars 48 forks source link

Docker container exits : file permissions #86

Open slfhstr opened 4 days ago

slfhstr commented 4 days ago

Using docker-compose and these volume settings :

    volumes:
      - '$PWD/data:/var/www/opentrashmail/data'
      - '$PWD/logs:/var/www/opentrashmail/logs'

On start, the container exits and the logs show :

Starting Open Trashmail
 [+] Starting php
 [+] Starting nginx
 [+] Setting up config.ini
 [+] Starting Mailserver
-ash: can't create /var/www/opentrashmail/logs/mailserver.log: Permission denied

even though SKIP_FILEPERMISSIONS=true

ceramicwhite commented 3 days ago

the container service is run as user nginx(100:101) and if docker created your data dir on start it will most like be owned by root unless using rootless docker.

run chown on the data dir: sudo chown -R 100:101 ./data

then restart the container

slfhstr commented 3 days ago

Thank you. I did that but the container still exited immediately. So I did the same on the ./logs directory and the container started ok.

docker logs show :

Starting Open Trashmail
 [+] Starting php
 [+] Starting nginx
 [+] Setting up config.ini
 [+] Starting Mailserver

But accessing via the app URL returns Internal Server Error

docker-compose.yml is :

services:
  opentrashmail:
    image: 'hascheksolutions/opentrashmail:1'
    container_name: opentrashmail
    volumes:
      - '$PWD/data:/var/www/opentrashmail/data'
      - '$PWD/logs:/var/www/opentrashmail/logs'
    environment:
      - URL=https://opentrashmail.domain.uk
      - DOMAINS=domain.uk
      - DATEFORMAT=D.M.YYYY HH:mm
      - SKIP_FILEPERMISSIONS=true
      - DISCARD_UNKNOWN=false
      - ADMIN_ENABLED=true
      - ADMIN_PASSWORD=xxxxxxxxx
      - ADMIN=me@email.com
      # - PASSWORD=123456
      # - ALLOWED_IPS=192.168.0.0/16,2a02:ab:cd:ef::/60
      # - ATTACHMENTS_MAX_SIZE=10000000
      # - MAILPORT_TLS=465
      # - TLS_CERTIFICATE=cert.pem
      # - TLS_PRIVATE_KEY=key.pem
      # - WEBHOOK_URL=https://example.com/webhook
    labels:
      - traefik.docker.network=traefik
      - traefik.port=80
      - traefik.port=25
      - "traefik.enable=true"
      - "traefik.http.routers.opentrashmail.rule=Host(`opentrashmail.domain.uk`)"
      - "traefik.http.routers.opentrashmail.entrypoints=websecure"
      - "traefik.http.routers.opentrashmail.tls.certresolver=letsencrypt"
    networks:
      - traefik

networks:
  traefik:
    external: true

If you have any thoughts on this, I'd be grateful. Letsencrypt generated by Traefik and the domain shows valid certificate in browser. No errors in Traefik dashboard - all services running.