[GH-ISSUE #86] Docker container exits : file permissions #61

Open
opened 2026-02-25 23:39:45 +03:00 by kerem · 3 comments
Owner

Originally created by @slfhstr on GitHub (Jun 30, 2024).
Original GitHub issue: https://github.com/HaschekSolutions/opentrashmail/issues/86

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

Originally created by @slfhstr on GitHub (Jun 30, 2024). Original GitHub issue: https://github.com/HaschekSolutions/opentrashmail/issues/86 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`
Author
Owner

@ceramicwhite commented on GitHub (Jul 2, 2024):

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

<!-- gh-comment-id:2202274004 --> @ceramicwhite commented on GitHub (Jul 2, 2024): 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
Author
Owner

@slfhstr commented on GitHub (Jul 2, 2024):

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.

<!-- gh-comment-id:2202430181 --> @slfhstr commented on GitHub (Jul 2, 2024): 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.
Author
Owner

@slfhstr commented on GitHub (Jul 16, 2024):

OK, after some tinkering, I now have the container starting and the site loads a page (not tested further yet).
In case it helps others, this is my working docker-compose.yml with Traefik support :

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

networks:
  traefik:
    external: true

And in config.ini I have this :

URL="https://opentrashmail.mydomain.uk"

I guess this can be closed after you have reviewed unless you have any comments.

<!-- gh-comment-id:2230583473 --> @slfhstr commented on GitHub (Jul 16, 2024): OK, after some tinkering, I now have the container starting and the site loads a page (not tested further yet). In case it helps others, this is my working `docker-compose.yml` with Traefik support : ``` services: opentrashmail: image: 'hascheksolutions/opentrashmail:1' container_name: opentrashmail restart: always volumes: - '$PWD/data:/var/www/opentrashmail/data' - '$PWD/logs:/var/www/opentrashmail/logs' environment: - URL=https://opentrashmail.mydomain.uk - DOMAINS=mydomain.uk - DATEFORMAT=D.M.YYYY HH:mm - SKIP_FILEPERMISSIONS=false - DISCARD_UNKNOWN=false - ADMIN_ENABLED=true - ADMIN_PASSWORD=xxxxxxxxxx - ADMIN=me@mydomain.uk - MAILPORT_TLS=465 # - PASSWORD=123456 # - ALLOWED_IPS=192.168.0.0/16,2a02:ab:cd:ef::/60 # - ATTACHMENTS_MAX_SIZE=10000000 # - TLS_CERTIFICATE=cert.pem # - TLS_PRIVATE_KEY=key.pem # - WEBHOOK_URL=https://example.com/webhook labels: - traefik.docker.network=traefik - traefik.port=8080 - traefik.port=25 - traefik.port=465 - traefik.http.services.opentrashmail.loadbalancer.server.port=80 - "traefik.enable=true" - "traefik.http.routers.opentrashmail.rule=Host(`opentrashmail.mydomain.uk`)" - "traefik.http.routers.opentrashmail.entrypoints=websecure" - "traefik.http.routers.opentrashmail.tls.certresolver=letsencrypt" networks: - traefik networks: traefik: external: true ``` And in `config.ini` I have this : ``` URL="https://opentrashmail.mydomain.uk" ``` I guess this can be closed after you have reviewed unless you have any comments.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentrashmail#61
No description provided.