title: Making Nextcloud Docker accessible from local network
body: <p>I installed a fully dockerized Nextcloud server on Ubuntu LTS 20.04.</p>
  
  <p>Right now, it is accessible via nginx from the subdomain I assigned to it, with a SSL certificate from Lets Encrypt.</p>
  
  <p>I would like to be able to access it from a local IP from within the network on port <code>8140</code>.</p>
  
  <p>I tried adding the ports to the <code>docker-compose.yml</code> file with: </p>
  
  <pre><code>ports:
            - "8140:8140"
  </code></pre>
  
  <p>But the ports get assigned to <code>0.0.0.0</code> instead of the machine's IP address.</p>
  
  <p>Anyone knows how to expose the container to the local network?</p>
  
  <p>Here's an example of the <code>docker-compose.yml</code> I used:</p>
  
  <pre><code>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
        - "8140:8140"
      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:
        - db:/var/lib/mysql
        - /etc/localtime:/etc/localtime:ro
      environment:
        - MYSQL_ROOT_PASSWORD=toor
        - MYSQL_PASSWORD=mysql
        - MYSQL_DATABASE=nextcloud
        - MYSQL_USER=nextcloud
      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
        - ./app/data:/var/www/html/data
        - ./app/themes:/var/www/html/themes
        - /etc/localtime:/etc/localtime:ro
      environment:
        - VIRTUAL_HOST=nextcloud.YOUR-DOMAIN
        - LETSENCRYPT_HOST=nextcloud.YOUR-DOMAIN
        - LETSENCRYPT_EMAIL=YOUR-EMAIL
      restart: unless-stopped
  
  volumes:
    nextcloud:
    db:
  
  networks:
    nextcloud_network:
  </code></pre>