Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker container exits : file permissions #86

Open
slfhstr opened this issue Jun 30, 2024 · 3 comments
Open

Docker container exits : file permissions #86

slfhstr opened this issue Jun 30, 2024 · 3 comments

Comments

@slfhstr
Copy link

slfhstr commented Jun 30, 2024

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
Copy link

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
Copy link
Author

slfhstr commented 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.

@slfhstr
Copy link
Author

slfhstr commented 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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants