Hello,
I have issues with my docker configuration.
MariaDB and Nextcloud are working will.
But nginx isnt working as expected.
My docker-compose.yaml looks like:
version: ‘3.3’
services:
mariadb:
image: mariadb
…
nextcloud:
image: nextcloud
volumes:
- type: bind
source : /var/lib/docker_data/nextcloud/data
target : /var/www/html/data
- type: bind
source : /var/lib/docker_data/nextcloud/config
target : /var/www/html/config
networks:
- nextcloud
restart: always
ports:
- "8080:80"
- "443:443"
container_name : nextcloud-nextcloud
depends_on:
- mariadb
nginx:
image: nginx
volumes:
- type: bind
source: /var/lib/docker_data/nginx/conf.d
target: /etc/nginx/conf.d:rw
- type: bind
source: /var/lib/docker_data/nginx/vhost.d
target: /etc/nginx/vhost.d:rw
- type: bind
source: /var/lib/docker_data/nginx/html
target: /usr/share/nginx/html:rw
- type: bind
source: /var/lib/docker_data/nginx/certs
target: /etc/nginx/certs
- type: bind
source: /var/lib/docker_data/nginx/docker.sock
target: /var/run/docker.sock:ro
networks:
- nextcloud
restart: always
#ports:
# - "80:80"
# - "443:443"
container_name: nextcloud-nginx
depends_on:
- mariadb
- nextcloud
networks:
nextcloud:
driver: bridge
When I’m starting all containers the db comes up and nextcloud is running on port 8080
netstat -an | grep :80 | grep -i listen
tcp6 0 0 :::8080 :::* LISTEN
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
272d284f1a8c nginx “nginx -g 'daemon of…” 9 minutes ago Up 9 minutes 80/tcp nextcloud-nginx
f9ca13ea5e36 nextcloud “/entrypoint.sh apac…” 9 minutes ago Up 9 minutes 0.0.0.0:443->443/tcp, 0.0.0.0:8080->80/tcp nextcloud-nextcloud
dc1ee9f21807 mariadb “docker-entrypoint.s…” 9 minutes ago Up 9 minutes 3306/tcp nextcloud-mariadb
So far it works as expected.
When I’m stopping the container (docker stop nextcloud-nextcloud) I cant connect to port 8080 via webbrowser anymore and netstat said noting is listen on port 8080
BUT when I’m trying to open an connection at port 80, the default site from nginx comes up.
Why? I didn’t any port forwarding from the docker so port 80 shouldn’t be reachable from outside.
netstat -an | grep :80 | grep -i listen
delivers and empty list
Just to be sure, stopping the container with docker stop nextcloud-nginx
Result is as expected: No connection anymore to port 80.
-> So, question: Why nginx is reachable from outside?
Next step: Changing to port configuration:
nextcloud:
image: nextcloud
volumes:
- type: bind
source : /var/lib/docker_data/nextcloud/data
target : /var/www/html/data
- type: bind
source : /var/lib/docker_data/nextcloud/config
target : /var/www/html/config
networks:
- nextcloud
restart: always
ports:
- “8080:80”
# - “443:443”
container_name : nextcloud-nextcloud
depends_on:
- mariadb
nginx:
image: nginx
volumes:
- type: bind
source: /var/lib/docker_data/nginx/conf.d
target: /etc/nginx/conf.d:rw
- type: bind
source: /var/lib/docker_data/nginx/vhost.d
target: /etc/nginx/vhost.d:rw
- type: bind
source: /var/lib/docker_data/nginx/html
target: /usr/share/nginx/html:rw
- type: bind
source: /var/lib/docker_data/nginx/certs
target: /etc/nginx/certs
- type: bind
source: /var/lib/docker_data/nginx/docker.sock
target: /var/run/docker.sock:ro
networks:
- nextcloud
restart: always
ports:
- "80:80"
- "443:443"
container_name: nextcloud-nginx
depends_on:
- mariadb
` - nextcloud`
Now should be port 80 and 443 provided by nginx, port 8080 still with nextcloud
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7d39bbf8d379 nginx “nginx -g 'daemon of…” 12 seconds ago Up 9 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp nextcloud-nginx
a01de1d07587 nextcloud “/entrypoint.sh apac…” 14 seconds ago Up 12 seconds 0.0.0.0:8080->80/tcp nextcloud-nextcloud
161cc81c1387 mariadb “docker-entrypoint.s…” 15 seconds ago Up 13 seconds 3306/tcp nextcloud-mariadb
Looks good so far.
netstat -an | grep :80 | grep -i listen
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 :::8080 :::* LISTEN
netstat -an | grep :443 | grep -i listen
tcp6 0 0 :::443 :::* LISTEN
On port 80 the standard site from nginx appears.
On port 8080 the nextcloud is available
But nothing on port 443
So, why it’s not possible to use https? What do i have forgotten?
Many many thanks