nextcloud in docker-compose not reachable - nginx

I am using docker compose on my raspberry pi. In the yaml file I have a nextcloud and nginx (for outside communication). But as my raspberry pi is in my private network, I want to have also a direct connection for my immobile setup.
Something like an ip: 192.168.0.100:1080
What I have tried:
version: '3'
volumes:
nextcloud-data:
nextcloud-db:
npm-data:
npm-ssl:
npm-db:
networks:
frontend:
backend:
services:
nextcloud-app:
image: nextcloud
restart: always
ports:
- "1080:80"
- "1443:443"
volumes:
- nextcloud-data:/var/www/html
environment:
- MYSQL_PASSWORD=replace-with-secure-password
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_HOST=nextcloud-db
networks:
- frontend
- backend
nextcloud-db:
image: mariadb
restart: always
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- nextcloud-db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=replace-with-secure-password
- MYSQL_PASSWORD=replace-with-secure-password
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
networks:
- backend
npm-app:
image: jc21/nginx-proxy-manager:latest
restart: always
ports:
- "80:80"
- "81:81"
- "443:443"
environment:
- DB_MYSQL_HOST=npm-db
- DB_MYSQL_PORT=3306
- DB_MYSQL_USER=npm
- DB_MYSQL_PASSWORD=replace-with-secure-password
- DB_MYSQL_NAME=npm
volumes:
- npm-data:/data
- npm-ssl:/etc/letsencrypt
networks:
- frontend
- backend
npm-db:
image: jc21/mariadb-aria:latest
restart: always
environment:
- MYSQL_ROOT_PASSWORD=replace-with-secure-password
- MYSQL_DATABASE=npm
- MYSQL_USER=npm
- MYSQL_PASSWORD=replace-with-secure-password
volumes:
- npm-db:/var/lib/mysql
networks:
- backend
Additional information
The docker is started with docker-compose up -d
Nginx is not configured yet
Nextcloud is not configured yet
But with this approach the address 192.168.0.100:1080 does not resolve. Is this the right way to do it or why is the port 1080 not reachable?

Related

Can't get a Docker image of both PHPMyAdmin and MariaDB to work together

I'm using Docker and a docker-compose.yml file to pop up a WordPress site using Bitnami and MariaDB. With just these two services alone, everything is fine, but I have no way to view/access the data in MariaDB. To solve the issue, I added the PHPMyAdmin service to the compose file since I'm familiar with that service. However, one of two problems happen: either all three services stay up and work fine and I can't login to PHPMyAdmin, or MariaDB shuts down every time immediately after starting up and the whole image doesn't work.
This configuration keeps the image up, but doesn't let me login to PHPMyAdmin...
services:
# Database
mariadb:
image: docker.io/bitnami/mariadb:latest
container_name: test_mariadb_database
volumes:
- 'mariadb_data:/bitnami/mariadb'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=test_bn_wp
- MARIADB_DATABASE=test_bitnami_wordpress
networks:
- test_bn
# phpmyadmin
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: test_pma
links:
- mariadb
environment:
PMA_HOST: mariadb
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8081:80
# Wordpress
wordpress:
image: docker.io/bitnami/wordpress:latest
ports:
- '80:8080'
- '443:8443'
restart: always
container_name: test_bitnami_wordpress
volumes: ['./docroot:/bitnami/wordpress']
depends_on:
- mariadb
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- WORDPRESS_DATABASE_HOST=mariadb
- WORDPRESS_DATABASE_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=test_bn_wp
- WORDPRESS_DATABASE_NAME=test_bitnami_wordpress
networks:
- test_bn
networks:
test_bn:
volumes:
mariadb_data:
driver: local
wordpress_data:
driver: local
So I change to this configuration, thinking that the password can't be blank, but it causes MariaDB to shut down immediately after starting up, thus rendering the whole image useless...
services:
# Database
mariadb:
image: docker.io/bitnami/mariadb:latest
container_name: test_mariadb_database
volumes:
- 'mariadb_data:/bitnami/mariadb'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=no
- MARIADB_USER=test_bn_wp
- MARIADB_PASSWORD=test_password
- MARIADB_ROOT_PASSWORD=test_password
- MARIADB_DATABASE=test_bitnami_wordpress
networks:
- test_bn
# phpmyadmin
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: test_pma
links:
- mariadb
environment:
PMA_HOST: mariadb
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8081:80
# Wordpress
wordpress:
image: docker.io/bitnami/wordpress:latest
ports:
- '80:8080'
- '443:8443'
restart: always
container_name: test_bitnami_wordpress
volumes: ['./docroot:/bitnami/wordpress']
depends_on:
- mariadb
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- WORDPRESS_DATABASE_HOST=mariadb
- WORDPRESS_DATABASE_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=test_bn_wp
- WORDPRESS_DATABASE_NAME=test_bitnami_wordpress
networks:
- test_bn
networks:
test_bn:
volumes:
mariadb_data:
driver: local
wordpress_data:
driver: local
Edit - This is the error I get when trying to login to PHPMyAdmin with the first config.

connecting the certificate in the container wordpress+apache

Need help connecting the certificate. For example, the image is ready docker wordpress bitnami. How to configure ssl for apache in container using certbot?
Docker-compose:
version: '2'
services:
mariadb:
image: docker.io/bitnami/mariadb:10.6
volumes:
- 'mariadb_data:/bitnami/mariadb'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=bn_wordpress
- MARIADB_DATABASE=bitnami_wordpress
wordpress:
image: docker.io/bitnami/wordpress:6
ports:
- '80:8080'
- '443:8443'
volumes:
- 'wordpress_data:/bitnami/wordpress'
depends_on:
- mariadb
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- WORDPRESS_DATABASE_HOST=mariadb
- WORDPRESS_DATABASE_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=bn_wordpress
- WORDPRESS_DATABASE_NAME=bitnami_wordpress

How to connect wordpress install and cli docker

I am having great trouble with this, Trying to add wp cli to my wordpress installation with docker-compose but cant get it done as im getting an error when trying to connect the two in docker compose - IM getting an error about duplicate volumes.
Can you see what this is?
version: '3.3'
services:
db:
image: mysql
restart: always
volumes:
- mysql_data:/var/lib/mysql
- ./database/init:/docker-entrypoint-initdb.d/:ro
environment:
- MYSQL_ROOT_PASSWORD=admin
- MYSQL_DATABASE=mydb_assdf
- MYSQL_USER=admin
- MYSQL_PASSWORD=admin
security_opt:
- seccomp:unconfined
wordpress:
image: wordpress
depends_on:
- db
- phpmyadmin
ports:
- '8000:80'
restart: always
volumes:
- ./wordpress:/var/www/html
- wp_data:/var/www/html
environment:
- WORDPRESS_DB_HOST=db:3306
- WORDPRESS_DB_USER=admin
- WORDPRESS_DB_PASSWORD=admin
- WORDPRESS_DB_NAME=mydb_assdf
- WORDPRESS_TABLE_PREFIX=adsf_
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
- PMA_HOST=db
- MYSQL_ROOT_PASSWORD=admin
wpcli:
image: wordpress:cli
restart: always
depends_on:
- wordpress
volumes:
- wp_data:/var/www/html
- ./default/:/var/www/html/wp-content
ports:
- '1111:80'
volumes:
mysql_data:
driver: local
wp_data:
driver: local

Traefik not routing to other containers

I've set up Traefik and Portainer on my server running Ubuntu 20.04 that is in my front room (I used this guide and this one, but didn't set up the default IP whitelist in the second tutorial as I want it to be a publicly accessible webserver). Both apps work and appear to be using HTTPS. I can manage and create containers in Portainer.
To test out my configuration, I added two containers - MySQL and Wordpress. I added in the Traefik labels from the above tutorials like when I set up Traefik, and I set the Wordpress container's domain name in Portainer, but whenever I try to access the Wordpress site at that domain, I get a Bad Gateway error (just the words 'Bad Gateway', not even a status code).
I'm not sure where I've gone wrong. Here are my configuration files:
traefik.yml:
api:
dashboard: true
entryPoints:
http:
address: ":80"
https:
address: ":443"
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
filename: /config.yml
version: '3'
services:
traefik:
image: traefik:v2.0
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/traefik.yml:/traefik.yml:ro
- ./data/acme.json:/acme.json
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`traefik.mywebsite.com`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=michael:$$apr1$$.m1mfSB0$$6Ypx6rfih8y.vHkNQe9rJ0"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`traefik.mywebsite.com`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=http"
- "traefik.http.routers.traefik-secure.service=api#internal"
networks:
proxy:
external: true
certificatesResolvers:
http:
acme:
email: me#myemail.com
storage: acme.json
httpChallenge:
entryPoint: http
config.yml:
http:
middlewares:
https-redirect:
redirectScheme:
scheme: https
docker-compose.yml:
version: '3'
services:
traefik:
image: traefik:v2.0
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/traefik.yml:/traefik.yml:ro
- ./data/acme.json:/acme.json
- ./data/config.yml:/config.yml:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`traefik.mywebsite.com`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=michael:$$apr1$$.m1mfSB0$$6Ypx6rfih8y.vHkNQe9rJ0"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`traefik.mywebsite.com`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=http"
- "traefik.http.routers.traefik-secure.service=api#internal"
networks:
proxy:
external: true
Wordpress/MySQL docker-compose.yml:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: admin
WORDPRESS_DB_PASSWORD: password
WORDPRESS_DB_NAME: wordpressdb
volumes:
- wordpress:/var/www/html
networks:
- proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.wordpress.entrypoints=http"
- "traefik.http.routers.wordpress.rule=Host(`myblog.com`)"
- "traefik.http.routers.wordpress.middlewares=https-redirect#file"
- "traefik.http.routers.wordpress-secure.entrypoints=https"
- "traefik.http.routers.wordpress-secure.rule=Host(`myblog.com`)"
- "traefik.http.routers.wordpress-secure.tls=true"
- "traefik.http.routers.wordpress-secure.tls.certresolver=http"
- "traefik.http.routers.wordpress-secure.service=wordpress"
- "traefik.http.services.wordpress.loadbalancer.server.port=9000"
- "traefik.docker.network=proxy"
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: username
MYSQL_PASSWORD: password
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
networks:
- proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.mysql.entrypoints=http"
- "traefik.http.routers.mysql.middlewares=https-redirect#file"
- "traefik.http.routers.mysql-secure.entrypoints=https"
- "traefik.http.routers.mysql-secure.tls=true"
- "traefik.http.routers.mysql-secure.tls.certresolver=http"
- "traefik.http.routers.mysql-secure.service=mysql"
- "traefik.http.services.mysql.loadbalancer.server.port=9000"
- "traefik.docker.network=proxy"
volumes:
wordpress:
db:
networks:
proxy:
external: true
I can provide the Portainer docker-compose.yml file too if needed, but I don't really think it's necessary. Any help here would be great!
For network connectivity between the different applications you must create the network in one of your applications. I would do that in your traefik docker-compose.yml
Meaning, that in your traefik compose file you must NOT specify the proxy network as external, because you create it internally in that application like this:
networks:
proxy:
In your Wordpress/MySQL docker-compose.yml you must specify a name for the external network like this:
networks:
proxy:
external:
name: "traefik_proxy"
When you create a new application using compose, everything in the application gets a prefix, that is the directoryname in which the compose file is placed.
Meaning the above example only works if your traefik compose file is placed in a directory named "traefik"
This should fix your issue with connectivity.

multiple docker compose container - single ip

I have this application.
How can I assign a single ip-address to the web-service and use the database within?
version: "2"
services:
web:
image: kartoffeltoby/typo3:latest
hostname: localhost
container_name: web
ports:
- 80:80
link:
- db:database
volumes:
- ./www/:/var/www/
environment:
- DOCROOT=/var/www/web
- PAGESPEED=Off
db:
image: mysql:5.6
hostname: database
volumes:
- ./DB/:/var/lib/mysql/
- ./db/:/var/tmp/db
environment:
- MYSQL_ROOT_PASSWORD=passwort
The solution is:
network_mode: service:web
version: "2"
services:
typo3:
image: kartoffeltoby/typo3:latest
hostname: axdbw.vagrant
container_name: typo3
volumes:
- ./www/:/var/www/
environment:
- DOCROOT=/var/www/web
- PAGESPEED=Off
networks:
mynet:
ipv4_address: 172.16.47.14
db:
image: mysql:5.6
volumes:
- ./DB/:/var/lib/mysql/
- ./db/:/var/tmp/db
environment:
- MYSQL_ROOT_PASSWORD=passwort
network_mode: service:web
networks:
mynet:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.47.0/24
There is no reason to use a specific IP. The solution can be as simple as this:
version: "3"
services:
typo3:
image: kartoffeltoby/typo3:latest
container_name: typo3
networks:
- mynet
db:
image: mysql:5.6
network_mode: "service:typo3"
networks:
mynet:
driver: bridge
This will place the db container onto the same IP as the typo3 container. Beware of possible port collisions.
In my use-case, I had to avoid nasty cross origin errors. Hosting the database on the same IP as my frontend container helped get around those issues.

Resources