NiFi 1.14.0 Docker-Compose/Cluster not working - docker

Please help, I have issue i can't make NiFi to work in version 1.14.0 via docker-compose I have problem with TLS certificate.
I don't know how to set up ENV var so TSL works. My approach was to try to set it all up on start but i failed.
I cant find any template online or reference the only is what i can read https://nifi.apache.org/docs.html and that isnt so helpful.
version: "3.3"
services:
zookeeper:
hostname: zookeeper
container_name: zookeeper
image: 'bitnami/zookeeper:latest'
volumes:
- data_share:/data_share
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
- ZOO_TLS_CLIENT_ENABLE=true
- ZOO_TLS_PORT_NUMBER=3181
- 'ZOO_TLS_CLIENT_KEYSTORE_FILE=/data_share/keystore.p12'
- 'ZOO_TLS_CLIENT_KEYSTORE_PASSWORD=cef4529207f19b4881b8f0f7f51e9fa9'
- 'ZOO_TLS_CLIENT_TRUSTSTORE_FILE=/data_share/truststore.p12'
- 'ZOO_TLS_CLIENT_TRUSTSTORE_PASSWORD=2b965c3a7748a3da3c6bf71377c8f5db'
networks:
netnifi:
ipv4_address: 10.40.0.10
nifi_1:
image: apache/nifi:1.14.0
tty: true
stdin_open: true
privileged: true
ports:
- 8443:8443
volumes:
- data_share:/opt/nifi/nifi-current/conf/
environment:
- NIFI_SECURITY_NEEDCLIENTAUTH=true
- NIFI_CLUSTER_PROTOCOL_IS_SECURE=true
- NIFI_SENSITIVE_PROPS_KEY=cef4529207f19b4881b8f0f7f51e9fa9
- 'NIFI_SECURITY_KEYSTORE=/opt/nifi/nifi-current/conf/keystore.p12'
- NIFI_SECURITY_KEYPASSWD=cef4529207f19b4881b8f0f7f51e9fa9
- NIFI_SECURITY_KEYSTOREPASSWD=cef4529207f19b4881b8f0f7f51e9fa9
- NIFI_SECURITY_KEYSTORETYPE=PKCS12
- 'NIFI_SECURITY_TRUSTSTORE=/opt/nifi/nifi-current/conf/truststore.p12'
- NIFI_SECURITY_TRUSTSTORETYPE=PKCS12
- NIFI_SECURITY_TRUSTSTOREPASSWD=2b965c3a7748a3da3c6bf71377c8f5db
- SINGLE_USER_CREDENTIALS_USERNAME=admin
- SINGLE_USER_CREDENTIALS_PASSWORD=ctsBtRBKHRAx69EqUghvvgEvjnaLjFEB
- NIFI_WEB_HTTPS_PORT=8443
- NIFI_CLUSTER_IS_NODE=true
- NIFI_CLUSTER_NODE_PROTOCOL_PORT=8082
- NIFI_ZK_CONNECT_STRING=zookeeper:3181
- NIFI_ELECTION_MAX_WAIT=1 min
networks:
netnifi:
ipv4_address: 10.40.0.20
nifi_2:
image: apache/nifi:1.14.0
tty: true
stdin_open: true
privileged: true
ports:
- 8444:8443
volumes:
- data_share:/home/data_share
environment:
- NIFI_SECURITY_NEEDCLIENTAUTH=true
- NIFI_CLUSTER_PROTOCOL_IS_SECURE=true
- NIFI_SENSITIVE_PROPS_KEY=cef4529207f19b4881b8f0f7f51e9fa9
- 'NIFI_SECURITY_KEYSTORE=/home/data_share/keystore.p12'
- NIFI_SECURITY_KEYPASSWD=cef4529207f19b4881b8f0f7f51e9fa9
- NIFI_SECURITY_KEYSTOREPASSWD=cef4529207f19b4881b8f0f7f51e9fa9
- NIFI_SECURITY_KEYSTORETYPE=PKCS12
- 'NIFI_SECURITY_TRUSTSTORE=/home/data_share/truststore.p12'
- NIFI_SECURITY_TRUSTSTORETYPE=PKCS12
- NIFI_SECURITY_TRUSTSTOREPASSWD=2b965c3a7748a3da3c6bf71377c8f5db
- SINGLE_USER_CREDENTIALS_USERNAME=admin
- SINGLE_USER_CREDENTIALS_PASSWORD=ctsBtRBKHRAx69EqUghvvgEvjnaLjFEB
- NIFI_WEB_HTTPS_PORT=8443
- NIFI_CLUSTER_IS_NODE=true
- NIFI_CLUSTER_NODE_PROTOCOL_PORT=8082
- NIFI_ZK_CONNECT_STRING=zookeeper:3181
- NIFI_ELECTION_MAX_WAIT=1 min
networks:
netnifi:
ipv4_address: 10.40.0.30
nifi_3:
image: apache/nifi:1.14.0
tty: true
stdin_open: true
privileged: true
ports:
- 8445:8443
volumes:
- data_share:/home/data_share
environment:
- NIFI_SECURITY_NEEDCLIENTAUTH=true
- NIFI_CLUSTER_PROTOCOL_IS_SECURE=true
- NIFI_SENSITIVE_PROPS_KEY=cef4529207f19b4881b8f0f7f51e9fa9
- 'NIFI_SECURITY_KEYSTORE=/home/data_share/keystore.p12'
- NIFI_SECURITY_KEYPASSWD=cef4529207f19b4881b8f0f7f51e9fa9
- NIFI_SECURITY_KEYSTOREPASSWD=cef4529207f19b4881b8f0f7f51e9fa9
- NIFI_SECURITY_KEYSTORETYPE=PKCS12
- 'NIFI_SECURITY_TRUSTSTORE=/home/data_share/truststore.p12'
- NIFI_SECURITY_TRUSTSTORETYPE=PKCS12
- NIFI_SECURITY_TRUSTSTOREPASSWD=2b965c3a7748a3da3c6bf71377c8f5db
- SINGLE_USER_CREDENTIALS_USERNAME=admin
- SINGLE_USER_CREDENTIALS_PASSWORD=ctsBtRBKHRAx69EqUghvvgEvjnaLjFEB
- NIFI_WEB_HTTPS_PORT=8443
- NIFI_CLUSTER_IS_NODE=true
- NIFI_CLUSTER_NODE_PROTOCOL_PORT=8082
- NIFI_ZK_CONNECT_STRING=zookeeper:3181
- NIFI_ELECTION_MAX_WAIT=1 min
networks:
netnifi:
ipv4_address: 10.40.0.40
networks:
netnifi:
driver: bridge
ipam:
config:
- subnet: 10.40.0.0/24
volumes:
data_share:
and for version 1.13.2 next docker-compose works perfectly
# maintainer="alex"
# repo="N/A"
# version="v.0.0.1"
# description="OWASP Lesson 1"
version: "3.3"
services:
zookeeper:
hostname: zookeeper
container_name: zookeeper
image: 'bitnami/zookeeper:latest'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
networks:
netnifi:
ipv4_address: 10.40.0.10
nifi_1:
image: apache/nifi:1.13.2
tty: true
stdin_open: true
privileged: true
ports:
- 8442:8080
volumes:
- data_share:/home/data_share
environment:
- NIFI_WEB_HTTP_PORT=8080
- NIFI_CLUSTER_IS_NODE=true
- NIFI_CLUSTER_NODE_PROTOCOL_PORT=8082
- NIFI_ZK_CONNECT_STRING=zookeeper:2181
- NIFI_ELECTION_MAX_WAIT=1 min
networks:
netnifi:
ipv4_address: 10.40.0.20
nifi_2:
image: apache/nifi:1.13.2
tty: true
stdin_open: true
privileged: true
ports:
- 8443:8080
volumes:
- data_share:/home/data_share
environment:
- NIFI_WEB_HTTP_PORT=8080
- NIFI_CLUSTER_IS_NODE=true
- NIFI_CLUSTER_NODE_PROTOCOL_PORT=8082
- NIFI_ZK_CONNECT_STRING=zookeeper:2181
- NIFI_ELECTION_MAX_WAIT=1 min
networks:
netnifi:
ipv4_address: 10.40.0.30
nifi_3:
image: apache/nifi:1.13.2
tty: true
stdin_open: true
privileged: true
ports:
- 8444:8080
volumes:
- data_share:/home/data_share
environment:
- NIFI_WEB_HTTP_PORT=8080
- NIFI_CLUSTER_IS_NODE=true
- NIFI_CLUSTER_NODE_PROTOCOL_PORT=8082
- NIFI_ZK_CONNECT_STRING=zookeeper:2181
- NIFI_ELECTION_MAX_WAIT=1 min
networks:
netnifi:
ipv4_address: 10.40.0.40
networks:
netnifi:
driver: bridge
ipam:
config:
- subnet: 10.40.0.0/24
volumes:
data_share:

Related

Traefik configuration for https external services and http for internal services

I have a working docker-compose.yaml configuration that allow me to easily expose my services on my public domain (mydomain.com). But now, I want to also expose some of my services on a local domain (myservice.lan) so need of https.
Here is my docker-compose.yaml:
version: '3.4'
services:
traefik:
image: traefik:2.5
container_name: traefik
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- ${CONFIG}/traefik/acme.json:/acme.json
- ${CONFIG}/traefik/rules.toml:/etc/traefik/rules.toml
command:
- --api.insecure=true
- --api.debug=true
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --providers.docker.watch=true
- --entrypoints.insecure.address=:80
- --entrypoints.secure.address=:443
- --certificatesresolvers.letsencrypt.acme.httpchallenge=true
- --certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=insecure
- --certificatesresolvers.letsencrypt.acme.email=my_mail
- --certificatesresolvers.letsencrypt.acme.storage=acme.json
- --certificatesresolvers.letsencrypt.acme.caServer=https://acme-v02.api.letsencrypt.org/directory
- --certificatesresolvers.letsencrypt.acme.keyType=EC256
- --providers.file=true
- --providers.file.filename=/etc/traefik/rules.toml
- --providers.file.watch=true
labels:
- traefik.http.middlewares.wss.headers.customrequestheaders.X-Forwarded-Proto=https
grafana:
image: grafana/grafana:latest
container_name: grafana
user: ${PUID}:${PGID}
restart: unless-stopped
volumes:
- ${DATA}/grafana:/var/lib/grafana
environment:
- GF_USERS_ALLOW_SIGN_UP=false
- GF_SERVER_DOMAIN=grafana.${DOMAIN}
- GF_SERVER_ROOT_URL=https://grafana.${DOMAIN}/
- GF_SERVER_SERVE_FROM_SUB_PATH=true
labels:
- traefik.enable=true
- traefik.http.routers.grafana.rule=Host(`grafana.${DOMAIN}`)
- traefik.http.routers.grafana.entrypoints=insecure
- traefik.http.middlewares.https-redirect.redirectscheme.scheme=https
- traefik.http.middlewares.https-redirect.redirectscheme.permanent=true
- traefik.http.routers.grafana-http.middlewares=https-redirect#docker
- traefik.http.routers.grafana-https.entrypoints=secure
- traefik.http.routers.grafana-https.rule=Host(`grafana.${DOMAIN}`)
- traefik.http.routers.grafana-https.tls=true
- traefik.http.routers.grafana-https.tls.certresolver=letsencrypt
esphome: #6052
image: esphome/esphome
container_name: esphome
restart: unless-stopped
privileged: true
volumes:
- ${CONFIG}/esphome:/config
- /etc/localtime:/etc/localtime:ro
labels:
- traefik.enable=true
- traefik.http.routers.esphome.rule=Host(`esphome.${DOMAIN_LOCAL}`)
- traefik.http.routers.esphome.entrypoints=insecure
- traefik.http.services.esphome.loadbalancer.server.port=6052
Grafana service is well exposed on my ${DOMAIN}(grafana.mydomain.com) but esphome (esphome.lan) doesn't work.
Does my configuration is bad ?

New version of traefik website is not working properly

I have had nextjs website running on nextjs, traefik 1.7 and docker. Website was working allright but because of a SSL certificate I had to change traefik version to 2.4 so I can load my bought SSL. Since that website is working as before but images won't load. Anyone who could help?
OLD docker-compose
version: '3'
services:
loadbalancer:
restart: unless-stopped
image: traefik:1.7
command: --docker
ports:
- "80:80"
- "443:443"
- "3000:3000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
- ./acme.json:/acme.json:rw
- ./traefik.toml:/traefik.toml:rw
- ./certs:/certs:rw
command:
- --debug=false
- --logLevel=ERROR
- --defaultentrypoints=https,http
- "--entryPoints=Name:http Address::80"
- "--entryPoints=Name:https Address::443 TLS"
- --docker.endpoint=unix:///var/run/docker.sock
- --docker.watch=true
- --docker.exposedbydefault=false
- --acme.email=admin#ssupat.sk
- --acme.storage=acme.json
- --acme.entryPoint=https
- --acme.onHostRule=true
- --acme.httpchallenge.entrypoint=https
security_opt:
- no-new-privileges:true
networks:
- ssupat
cms-postgresql:
restart: unless-stopped
image: 'bitnami/postgresql:latest'
environment:
- POSTGRESQL_USERNAME=ssupat_user
- POSTGRESQL_PASSWORD=password
- POSTGRESQL_DATABASE=ssupat_cms
ports:
- '5432'
networks:
- ssupat
volumes:
- ./db/:/bitnami/postgresql
ssupat-cms-strapi:
restart: unless-stopped
build:
context: ssupat-cms-strapi/
dockerfile: Dockerfile
environment:
DATABASE_CLIENT: postgres
DATABASE_NAME: ssupat_cms
DATABASE_HOST: cms-postgresql
DATABASE_PORT: 5432
DATABASE_USERNAME: ssupat_user
DATABASE_PASSWORD: password
networks:
- ssupat
security_opt:
- no-new-privileges:true
volumes:
- ./app:/srv/app
- ./public:/public/uploads
depends_on:
- "cms-postgresql"
labels:
traefik.frontend.rule: 'Host:cms.ssupat.sk'
traefik.frontend.redirect.regex: ^http?://cms.ssupat.sk/(.*)
traefik.frontend.redirect.replacement: https://cms.ssupat.sk/$${1}
traefik.frontend.redirect.permanent: true
traefik.http.routers.some-name.entryPoints: 'Port:80'
traefik.http.routers.ssupat-cms-strapi.rule: 'Host:cms.ssupat.sk'
traefik.http.routers.my-app.tls: true
traefik.http.routers.my-app.tls.certresolver: 'le-ssl'
traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent: true
traefik.enable: true
traefik.port: 80
traefik.protocol: http
security_opt:
- no-new-privileges:true
ssupat-web-nextjs:
restart: unless-stopped
build:
context: ssupat-web-nextjs/
dockerfile: Dockerfile
networks:
- ssupat
depends_on:
- "ssupat-cms-strapi"
- "cms-postgresql"
labels:
traefik.frontend.rule: 'Host:ssupat.sk,www.ssupat.sk'
traefik.frontend.redirect.regex: ^http?://ssupat.sk/(.*)
traefik.frontend.redirect.replacement: https://ssupat.sk/$${1}
traefik.frontend.redirect.regex: ^http?://www.ssupat.sk/(.*)
traefik.frontend.redirect.replacement: https://ssupat.sk/$${1}
traefik.frontend.redirect.permanent: true
traefik.http.routers.my-app.tls: true
traefik.http.routers.my-app.tls.certresolver: 'le-ssl'
traefik.enable: true
traefik.port: 3000
traefik.protocol: http
security_opt:
- no-new-privileges:true
networks:
ssupat:
driver: bridge
NEW docker-compose
version: '3.3'
networks:
ssupat:
driver: bridge
#networks:
#ssupat:
#external: true
services:
traefik:
#image: traefik:2.4
image: traefik:latest
container_name: traefik
volumes:
- ./certs/traefik-certs/:/etc/traefik/:ro
- /var/run/docker.sock:/var/run/docker.sock
networks:
- ssupat
ports:
- 80:80
- 443:443
- 8080:8080
#- 3000:3000
command:
- '--api.insecure=true'
- '--api.dashboard=true'
- '--api.debug=true'
- '--providers.docker=true'
- '--providers.docker.exposedByDefault=false'
- '--providers.file=true'
- '--providers.file.directory=/etc/traefik/'
- '--entrypoints.http=true'
- '--providers.docker.network=proxy'
- '--entrypoints.web.address=:80'
- '--entrypoints.websecure.address=:443'
- '--entrypoints.http.http.redirections.entrypoint.to=https'
- '--entrypoints.http.http.redirections.entrypoint.scheme=https'
#- '--entrypoints.http.http.redirections.entrypoint.permanent=true'
- '--entrypoints.https=true'
- '--log=true'
- '--log.level=DEBUG'
cms-postgresql:
restart: unless-stopped
image: 'bitnami/postgresql:latest'
environment:
- POSTGRESQL_USERNAME=ssupat_user
- POSTGRESQL_PASSWORD=password
- POSTGRESQL_DATABASE=ssupat_cms
#- POSTGRESQL_ENABLE_TLS=yes
#- POSTGRESQL_TLS_CERT_FILE=/opt/bitnami/postgresql/certs/certs.crt
#- POSTGRESQL_TLS_KEY_FILE=/opt/bitnami/postgresql/certs/private.key
#- POSTGRESQL_TLS_CA_FILE=/opt/bitnami/postgresql/certs/ssupat.sk.ca
ports:
- '5432'
networks:
- ssupat
volumes:
- ./db/:/bitnami/postgresql
#- ./certs/traefik-certs/certs:/opt/bitnami/postgresql/certs
#- ./pg_hba.conf:/opt/bitnami/postgresql/conf/pg_hba.conf
ssupat-cms-strapi:
restart: unless-stopped
build:
context: ssupat-cms-strapi/
dockerfile: Dockerfile
environment:
DATABASE_CLIENT: postgres
DATABASE_NAME: ssupat_cms
DATABASE_HOST: cms-postgresql
DATABASE_PORT: 5432
DATABASE_USERNAME: ssupat_user
DATABASE_PASSWORD: password
networks:
- ssupat
security_opt:
- no-new-privileges:true
volumes:
- ./app/:/srv/app
- ./public/:/public/uploads
depends_on:
- "cms-postgresql"
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.ssupat-cms-strapi.rule=Host(`cms.ssupat.sk`)'
- 'traefik.http.routers.ssupat-cms-strapi.entrypoints=websecure'
- 'traefik.http.routers.ssupat-cms-strapi.tls=true'
- 'traefik.http.routers.ssupat-cms-strapi.tls.options=default'
#- 'traefik.http.routers.ssupat-cms-strapi.middlewares=authelia#docker'
- 'traefik.http.services.ssupat-cms-strapi.loadbalancer.server.port=80'
#- 'traefik.port=80'
- 'traefik.docker.network=ssupat'
- 'traefik.http.middlewares.ssupat-cms-strapi.redirectregex.regex=^http://www.cms.ssupat.sk/(.*)'
- 'traefik.http.middlewares.ssupat-cms-strapi.redirectregex.replacement=https://cms.ssupat.sk/$${1}'
- 'traefik.http.middlewares.ssupat-cms-strapi.redirectregex.permanent=true'
ssupat-web-nextjs:
restart: unless-stopped
build:
context: ssupat-web-nextjs/
dockerfile: Dockerfile
networks:
- ssupat
security_opt:
- no-new-privileges:true
depends_on:
- "ssupat-cms-strapi"
- "cms-postgresql"
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.ssupat-web-nextjs.rule=Host(`ssupat.sk`) || Host(`www.ssupat.sk`)'
#- 'traefik.http.routers.ssupat-web-nextjs.rule=Host(`ssupat.sk`, `www.ssupat.sk`)'
- 'traefik.http.routers.ssupat-web-nextjs.entrypoints=web'
#- 'traefik.http.middlewares.force_https.redirectscheme.scheme=https
- 'traefik.http.routers.ssupat-web-nextjs-secure.rule=Host(`ssupat.sk`) || Host(`www.ssupat.sk`)'
- 'traefik.http.routers.ssupat-web-nextjs-secure.entrypoints=websecure'
- 'traefik.http.routers.ssupat-web-nextjs-secure.tls=true'
- 'traefik.http.routers.ssupat-web-nextjs-secure.tls.options=default'
- 'traefik.http.services.ssupat-web-nextjs-secure.loadbalancer.server.port=3000'
#- 'traefik.port=3000'
- 'traefik.docker.network=ssupat'
#- 'traefik.http.routers.ssupat-web-nextjs-secure.middlewares=ssupat-web-nextjs-redirect'
- 'traefik.http.middlewares.ssupat-web-nextjs-secure.redirectregex.regex=^http://ssupat.sk/(.*)'
- 'traefik.http.middlewares.ssupat-web-nextjs-secure.redirectregex.replacement="https://ssupat.sk/$${1}"'
- 'traefik.http.middlewares.ssupat-web-nextjs-secure.redirectregex.permanent=true'

I trying docker-compose script postgres connection with 2 backend spring boot application but conncetioon refuse erros

version: '3.3'
services:
#InfluxDB server
influx-db:
image: influxdb:1.8-alpine
container_name: influx-db
ports:
- 8086:8086
restart: always
volumes:
- db-data:/var/lib/influxdb
networks:
- local
#PostgreSQL Database for the application
postgresdb:
image: "postgres:12.0-alpine"
container_name: postgresdb
volumes:
- db-data:/var/lib/postgresql/data
ports:
- 5432:5432
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
restart: always
networks:
- local
#Fron-end Angular Application
fe:
build: './Frontend-Asset'
ports:
- 4201:4201
links:
- sm_abc_be
- sm_um_be
depends_on:
- sm_abc_be
- sm_um_be
networks:
- local
um_fe:
build: './Frontend-User'
ports:
- 4202:4202
links:
- sm_abc_be
- sm_um_be
depends_on:
- sm_abc_be
- sm_um_be
networks:
- local
#Back-end Spring Boot Application
sm_um_be:
build: './um_be'
ports:
- 8081:8081
restart: always
volumes:
- db-data/
links:
- postgresdb
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgresdb:5432/abcd
- SPRING_DATASOURCE_USERNAME=abc_user
- SPRING_DATASOURCE_PASSWORD=abcpassword
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
depends_on:
- postgresdb
networks:
- local
sm_am_be:
build: './am_be'
ports:
- 8082:8082
restart: always
volumes:
- db-data/
links:
- postgresdb
- influx-db
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgresdb:5432/am_uuid?currentSchema=abc
- SPRING_DATASOURCE_USERNAME=am_db_user
- SPRING_DATASOURCE_PASSWORD=abcpassword
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
depends_on:
- postgresdb
- influx-db
networks:
- local
#Volumes for DB data
volumes:
db-data:
networks:
local:
driver: bridge

Portainer Docker Swarm import secrets to compose

add Secrets in Portainer swarm and trying to import as variable any one could give example how i can import it to compose
version: '3.1'
services:
mongodb-sharded:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY=${MONGODB_KEY}
- MONGODB_ROOT_PASSWORD=${MONGODB_PASSWORD}
ports:
- "27017:27017"
working with portariner Docker Swarm Secret running mongodb sharded
version: '3.7'
secrets:
mongo-root-password:
external: true
mongo-key:
external: true
services:
mongodb-sharded:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
ports:
- "27017:27017"
secrets:
- mongo-key
- mongo-root-password
mongodb-sharded-2:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded-2
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
secrets:
- mongo-key
- mongo-root-password
mongodb-shard0-primary:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-primary
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=shard0
volumes:
- 'shard0_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password
mongodb-shard0-secondary:
image: docker.io/bitnami/mongodb-sharded:4.4
depends_on:
- mongodb-shard0-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-shard0-primary
- MONGODB_PRIMARY_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_REPLICA_SET_NAME=shard0
volumes:
- 'shard0_sec_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password
mongodb-shard1-primary:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-primary
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=shard1
volumes:
- 'shard1_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password
mongodb-shard1-secondary:
image: docker.io/bitnami/mongodb-sharded:4.4
depends_on:
- mongodb-shard1-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-shard1-primary
- MONGODB_PRIMARY_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_REPLICA_SET_NAME=shard1
volumes:
- 'shard1_sec_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password
mongodb-shard2-primary:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard2-primary
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=shard2
volumes:
- 'shard2_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password
mongodb-shard2-secondary:
image: docker.io/bitnami/mongodb-sharded:4.4
depends_on:
- mongodb-shard2-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard2-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-shard2-primary
- MONGODB_PRIMARY_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_REPLICA_SET_NAME=shard2
volumes:
- 'shard2_sec_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password
mongodb-cfg-primary:
image: docker.io/bitnami/mongodb-sharded:4.4
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg-primary
- MONGODB_SHARDING_MODE=configsvr
- MONGODB_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=cfgreplicaset
volumes:
- 'cfg_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password
mongodb-cfg-secondary:
image: docker.io/bitnami/mongodb-sharded:4.4
depends_on:
- mongodb-cfg-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_PRIMARY_ROOT_PASSWORD_FILE=/run/secrets/mongo-root-password
- MONGODB_REPLICA_SET_KEY_FILE=/run/secrets/mongo-key
- MONGODB_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_SHARDING_MODE=configsvr
volumes:
- 'cfg_sec_data:/bitnami'
secrets:
- mongo-key
- mongo-root-password
volumes:
shard0_data:
driver: local
shard0_sec_data:
driver: local
shard1_data:
driver: local
shard1_sec_data:
driver: local
shard2_data:
driver: local
shard2_sec_data:
driver: local
cfg_data:
driver: local
cfg_sec_data:
driver: local
Docker secrets will be mounted as files in the container under /run/secrets/secret-name (if no explicit mount point was specified). To use it, the application must be able to read the data from these files. That's not always supported. If anything, only a small part of the available variables can usually specified as file.
The official Docker mongodb Image states support only for
MONGO_INITDB_ROOT_USERNAME_FILE and MONGO_INITDB_ROOT_PASSWORD_FILE.
The readme from the bitnami/mongodb-sharded image doesn't provide any info, wether there is support for docker secrets.
The compose file with pre definied secrets for the official image would look something like that:
version: '3.1'
services:
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME_FILE: /run/secrets/mongodb-root-username
MONGO_INITDB_ROOT_PASSWORD_FILE: /run/secrets/mongodb-root-password
secrets:
- mongodb-root-username
- mongodb-root-password
secrets:
mongodb-root-username:
external: true
mongodb-root-password:
external: true

My docker-compose.yml couldn't build mysql5.7 container

I'm trying to build docker container for laravel with docker-compose.yml.
I hove to build database container for mysql5.7.
Mysql8 cannot be used on my server witch connected.
There is my docker-compose.yml file.
version: "3"
services:
app:
build:
context: ./docker/php
args:
- TZ=${TZ}
ports:
- ${APP_PORT}:8000
volumes:
- ${PROJECT_PATH}:/work
- ./docker/ash:/etc/profile.d
- ./docker/php/psysh:/root/.config/psysh
- ./logs:/var/log/php
- ./docker/php/php.ini:/usr/local/etc/php/php.ini
working_dir: /work
environment:
- DB_CONNECTION=mysql
- DB_HOST=db
- DB_DATABASE=${DB_NAME}
- DB_USERNAME=${DB_USER}
- DB_PASSWORD=${DB_PASS}
- TZ=${TZ}
- MAIL_HOST=${MAIL_HOST}
- MAIL_PORT=${MAIL_PORT}
- CACHE_DRIVER=redis
- SESSION_DRIVER=redis
- QUEUE_DRIVER=redis
- REDIS_HOST=redis
web:
image: nginx:1.17-alpine
depends_on:
- app
ports:
- ${WEB_PORT}:80
volumes:
- ${PROJECT_PATH}:/work
- ./logs:/var/log/nginx
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
environment:
- TZ=${TZ}
db:
image: mysql:5.7
volumes:
- db-store:/var/lib/mysql
- ./logs:/var/log/mysql
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
environment:
- MYSQL_DATABASE=${DB_NAME}
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASS}
- MYSQL_ROOT_PASSWORD=${DB_PASS}
- TZ=${TZ}
ports:
- ${DB_PORT}:3306
db-testing:
image: mysql:5.7
volumes:
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
tmpfs:
- /var/lib/mysql
- /var/log/mysql
environment:
- MYSQL_DATABASE=${DB_NAME}
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASS}
- MYSQL_ROOT_PASSWORD=${DB_PASS}
- TZ=${TZ}
ports:
- ${DB_TESTING_PORT}:3306
node:
image: node:12.13-alpine
tty: true
volumes:
- ${PROJECT_PATH}:/work
working_dir: /work
redis:
image: redis:5.0-alpine
volumes:
- redis-store:/data
mail:
image: mailhog/mailhog
ports:
- ${MAILHOG_PORT}:8025
volumes:
db-store:
redis-store:
When I execute "docker-compose build" in terminal, it's successfully done, but db container and db-testing container has status "EXIT: 1" or "EXIT: 2".
So, Could you teach me what's wrong.

Resources