Docker Community Forums

Share and learn in the Docker community.

Issues with ports (nextcloud / reverse proxy / letsencrypt)

This is my docker-compose.yml to create nextcloud, a proxy, database and lets encrypt:

version: '3'

services:

  proxy:
    image: jwilder/nginx-proxy:alpine
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
    container_name: nextcloud-proxy
    networks:
      - nextcloud_network
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./proxy/conf.d:/etc/nginx/conf.d:rw
      - ./proxy/vhost.d:/etc/nginx/vhost.d:rw
      - ./proxy/html:/usr/share/nginx/html:rw
      - ./proxy/certs:/etc/nginx/certs:ro
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    restart: unless-stopped

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: nextcloud-letsencrypt
    depends_on:
      - proxy
    networks:
      - nextcloud_network
    volumes:
      - ./proxy/certs:/etc/nginx/certs:rw
      - ./proxy/vhost.d:/etc/nginx/vhost.d:rw
      - ./proxy/html:/usr/share/nginx/html:rw
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: unless-stopped

  db:
    image: mariadb
    container_name: nextcloud-mariadb
    networks:
      - nextcloud_network
    volumes:
      - /srv/docker-persist/MariaDB/nextcloud-sql:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=NCPWROOT
      - MYSQL_PASSWORD=NCPW
      - MYSQL_DATABASE=NCDATABASE
      - MYSQL_USER=NCUSER
    restart: unless-stopped

  app:
    image: nextcloud:latest
    container_name: nextcloud-app
    networks:
      - nextcloud_network
    depends_on:
      - letsencrypt
      - proxy
      - db
    volumes:
      - nextcloud:/var/www/html
      - ./app/config:/var/www/html/config
      - ./app/custom_apps:/var/www/html/custom_apps
      - /mnt/NC:/var/www/html/data
      - ./app/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    environment:
      - VIRTUAL_HOST=sub.domain.tld
      - LETSENCRYPT_HOST=sub.domain.tld
      - LETSENCRYPT_EMAIL=e@mail.tld
    restart: unless-stopped

volumes:
  nextcloud:
  db:

networks:
  nextcloud_network:

But i can’t reach the nextcloud interface with sub.domain.tld or even localhost (http and https).
I checked the listened ports:

[user@nuc nextcloud]$ sudo lsof -i -P -n | grep LISTEN
sshd         379  root    3u  IPv4  16054      0t0  TCP *:21(LISTEN)
sshd         379  root    4u  IPv6  16056      0t0  TCP *:21(LISTEN)

So there is no port 80 or 443. I used this docker-compose nearly a year ago and it works. Maybe something changed.

docker ps -a shows me port 80 on container nextcloud-app:

[user@nuc nextcloud]$ sudo docker ps -a
CONTAINER ID   IMAGE                                    COMMAND                  CREATED          STATUS                          PORTS                    NAMES
83878373043f   nextcloud:latest                         "/entrypoint.sh apac…"   11 minutes ago   Up 11 minutes                   80/tcp                   nextcloud-app
c1746f7274d2   jrcs/letsencrypt-nginx-proxy-companion   "/bin/bash /app/entr…"   11 minutes ago   Up 11 minutes                                            nextcloud-letsencrypt
8228c7a83ef5   jwilder/nginx-proxy:alpine               "/app/docker-entrypo…"   11 minutes ago   Restarting (0) 31 seconds ago                            nextcloud-proxy
cf7d190d04b0   mariadb                                  "docker-entrypoint.s…"   11 minutes ago   Up 11 minutes                   3306/tcp                 nextcloud-mariadb

So i don’t know why i can’t reach nextcloud with port 80 or 443 and why
docker ps -a shows me port 80 but sudo lsof -i -P -n | grep LISTEN shows nothing at all.