Having major problems getting my moodle installation working behind a traefik container in docker swarm. No matter what I try, I get a bad gateway error (different hosts in the frontend rule). I've read various posts on stack overflow and tutorials but due to the amount of commands and different options available, my head is spinning. Could somebody point me in the right direction?
version: '3.7'
services:
traefik:
image: traefik:v1.6.2
networks:
- traefik-proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc/traefik/traefik.toml:/etc/traefik/traefik.toml
labels:
- traefik.docker.network=traefik-proxy
- traefik.http.routers.traefik-http.entrypoints=web
- traefik.port=8080
- traefik.enable=true
ports:
- "80:80"
- "8080:8080"
command: --api
mariadb:
image: bitnami/mariadb:latest
environment:
- MARIADB_USER=bn_moodle
- MARIADB_DATABASE=bitnami_moodle
- MARIADB_PASSWORD=bitnami
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- /var/mariadb_data:/bitnami
networks:
- database
- traefik-proxy
ports:
- "3306:3306"
moodle:
image: bitnami/moodle:latest
environment:
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- MOODLE_DATABASE_PASSWORD=bitnami
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 8000:80
volumes:
- /var/moodle_data:/bitnami
depends_on:
- mariadb
networks:
- database
- traefik-proxy
labels:
- traefik.enable=true
- traefik.http.routers.moodle.entrypoints=web
- traefik.port=80
- traefik.frontend.rule=Host:one.test.com
- traefik.docker.network=traefik-proxy
- traefik.backend=moodle.app
networks:
database:
driver: overlay
traefik-proxy:
external: true
volumes:
mariadb_data:
moodle_data:
At least following should be updated:
moodle uses port 8080, not 80. So, it can be a reason.
traefik.enable=false should be set for mariadb and traefik services as there is no sense to send a traffic to them
mariadb should have only database network - means isolation from traefik
make traefik more supportive with command: --providers.docker --api --api.insecure=true --providers.docker.watch true
Here is a config for Docker Compose that uses traefik:v2.0.
version: '3.7'
services:
traefik:
image: traefik:v2.0
networks:
- traefik-proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
labels:
- "traefik.enable=false"
ports:
- "80:80"
- "8080:8080"
command: --providers.docker --api --api.insecure=true --providers.docker.watch true
mariadb:
image: bitnami/mariadb:latest
labels:
- "traefik.enable=false"
environment:
- MARIADB_USER=bn_moodle
- MARIADB_DATABASE=bitnami_moodle
- MARIADB_PASSWORD=bitnami
- ALLOW_EMPTY_PASSWORD=yes
networks:
- database
moodle:
image: bitnami/moodle:latest
environment:
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- MOODLE_DATABASE_PASSWORD=bitnami
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 8000:8080
depends_on:
- mariadb
networks:
- database
- traefik-proxy
labels:
- "traefik.enable=true"
- "traefik.http.services.moodle.loadbalancer.server.port=8080"
- "traefik.http.routers.moodle.rule=HostRegexp(`{catchall:.*}`)"
- "traefik.docker.network=traefik-proxy"
networks:
database:
driver: bridge
traefik-proxy:
external: true
Run
docker-compose up -d
docker-compose logs -f
and when log displays lines like
moodle_1 | moodle 11:05:41.68 INFO ==> Running Moodle install script
moodle_1 | moodle 11:08:14.90 INFO ==> Persisting Moodle installation
moodle_1 | moodle 11:08:21.75 INFO ==> ** Moodle setup finished! **
moodle_1 |
moodle_1 | moodle 11:08:21.77 INFO ==> ** Starting cron **
moodle_1 | moodle 11:08:21.80 INFO ==> ** Starting Apache **
try to open http://localhost.
BTW, http://localhost:8080 will open Traefik dashboard. It's useful to see what's is managed and how.
Related
I would like to build a docker landscape. I use a container with a traefik (v2. 1) image and a mysql container for multiple databases.
traefik/docker-compose.yml
version: "3.3"
services:
traefik:
image: "traefik:v2.1"
container_name: "traefik"
restart: always
command:
- "--log.level=DEBUG"
- "--api=true"
- "--api.dashboard=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=proxy"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.traefik-dashboard.address=:8080"
- "--certificatesresolvers.devnik-resolver.acme.httpchallenge=true"
- "--certificatesresolvers.devnik-resolver.acme.httpchallenge.entrypoint=web"
#- "--certificatesresolvers.devnik-resolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.devnik-resolver.acme.email=####"
- "--certificatesresolvers.devnik-resolver.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "./letsencrypt:/letsencrypt"
- "./data:/etc/traefik"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
- "proxy"
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`devnik.dev`)"
- "traefik.http.routers.traefik.entrypoints=traefik-dashboard"
- "traefik.http.routers.traefik.tls.certresolver=devnik-resolver"
#basic auth
- "traefik.http.routers.traefik.service=api#internal"
- "traefik.http.routers.traefik.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.usersfile=/etc/traefik/.htpasswd"
#Docker Networks
networks:
proxy:
database/docker-compose.yml
version: "3.3"
services:
#MySQL Service
mysql:
image: mysql:5.7
container_name: mysql
restart: always
ports:
- "3306:3306"
volumes:
#persist data
- ./mysqldata/:/var/lib/mysql/
- ./init:/docker-entrypoint-initdb.d
networks:
- "mysql"
environment:
MYSQL_ROOT_PASSWORD: ####
TZ: Europe/Berlin
#Docker Networks
networks:
mysql:
driver: bridge
For the structure I want to control all projects via multiple docker-compose files. These containers should run on the same network as the traefik container and some with the mysql container.
This also works for the following case (but only sometimes)
dev-releases/docker-compose.yml
version: "3.3"
services:
backend:
image: "registry.gitlab.com/devnik/dev-releases-backend/master:latest"
container_name: "dev-releases-backend"
restart: always
volumes:
#laravel logs
- "./logs/backend:/app/storage/logs"
#cron logs
- "./logs/backend/cron.log:/var/log/cron.log"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dev-releases-backend.rule=Host(`dev-releases.backend.devnik.dev`)"
- "traefik.http.routers.dev-releases-backend.entrypoints=websecure"
- "traefik.http.routers.dev-releases-backend.tls.certresolver=devnik-resolver"
networks:
- proxy
- mysql
environment:
TZ: Europe/Berlin
#Docker Networks
networks:
proxy:
external:
name: "traefik_proxy"
mysql:
external:
name: "database_mysql"
As soon as I restart the containers in dev-releases/ via docker-compose up -d I get the typical error "Gateway timeout" when calling them in the browser.
As soon as I comment the network networks: #- mysql and restart the docker-compose in dev-releases/ it works again.
My guess is that I have not configured the external networks correctly. Is it not possible to use 2 external networks?
I'd like some container have access to the 'mysql' network but it should not be accessible for the whole traefik network.
Let me know if you need more information
EDIT (26.03.2020)
I make it running.
I put all my containers into one network "proxy". It seems mysql also have to be in the proxy network.
So I add following to database/docker-compose.yml
networks:
proxy:
external:
name: "traefik_proxy"
And removed the database_mysql network out of dev-releases/docker-compose.yml
based on the names of the files, your mysql network should be mysql_mysql.
you can verify this by executing
$> docker network ls
You are also missing a couple of labels for your services such as
traefik command line
- '--providers.docker.watch=true'
- '--providers.docker.swarmMode=true'
labels
- traefik.docker.network=proxy
- traefik.http.services.dev-releases-backend.loadbalancer.server.port=yourport
- traefik.http.routers.dev-releases-backend.service=mailcatcher
You can check this for more info
is there a way to expose rasa server with docker to slack without using ngrok (am using traefik), and i exposed it to "https://rasa.dev.x-hub.io" so when i try:
https://rasa.dev.x-hub.io/webhooks/slack/webhook
i get no response. as you can see below, everything is working fine.
rasa server:
(ignore tensorflow error)
action server:
duckling:
and the following is the docker-compose file:
version: "2"
services:
rasa:
image: registry.gitlab.com/xhub-org/p/xpeers/slackbot:{{img_version}}
container_name: rasa
labels:
- traefik.frontend.rule=Host:rasa.dev.x-hub.io
- traefik.port={{app_port}}
- traefik.docker.network=web
- traefik.enable=true
restart: always
networks: ['rasa-network']
command:
- run
- --cors
- "*"
- --enable-api
- --log-file
- out.log
- --connector
- slack
- --credentials
- slack_credentials.yml
- --endpoints
- endpoints.yml
- -m
- /models
depends_on:
- action_server
action_server:
image: registry.gitlab.com/xhub-org/p/xpeers/slackbot:{{img_version}}
container_name: rasa_action_1
networks: ['rasa-network']
command :
- run
- actions
duckling:
image: rasa/duckling:latest
networks: ['rasa-network']
ports:
- "8005:8005"
networks: {rasa-network: {}}
am also using Docker Container Registry integrated into GitLab, every project can
have its own space to store its Docker images.
Any help please !
solved my problem by adding :
networks:
- web
- rasa-network
and :
networks:
rasa-network:
web:
external: true
Full update:
version: "2"
services:
rasa:
image: registry.gitlab.com/xhub-org/p/xpeers/slackbot:{{img_version}}
container_name: rasa
labels:
- traefik.frontend.rule=Host:rasa.dev.x-hub.io
- traefik.port={{services.rasa.app_port}}
- traefik.docker.network=web
- traefik.enable=true
restart: always
networks:
- web
- rasa-network
command:
- run
- --cors
- "*"
- --enable-api
- --log-file
- out.log
- --connector
- slack
- --credentials
- slack_credentials.yml
- --endpoints
- endpoints.yml
- -m
- /models
ports:
- "5005:5005"
depends_on:
- action_server
action_server:
image: registry.gitlab.com/xhub-org/p/xpeers/slackbot:{{img_version}}
container_name: rasa_action_1
networks:
- rasa-network
command :
- run
- actions
ports:
- "5055:5055"
duckling:
image: rasa/duckling:latest
networks: ['rasa-network']
ports:
- "8005:8005"
networks:
rasa-network:
web:
external: true
Hi All I faced a small issue with the nifi cluster am creating with the below docker-compose file
services:
zookeeper:
hostname: zookeeper
container_name: zookeeper
image: 'bitnami/zookeeper:latest'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
networks:
- efactory-network
nifi:
image: apache/nifi:1.9.2
ports:
- 8080:8080 # Unsecured HTTP Web Port
- 8081:8081
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
- nifi.security.needClientAuth=false
networks:
- efactory-network
volumes:
- state:/opt/nifi/nifi-1.9.2/state
- conf:/opt/nifi/nifi-1.9.2/conf
- content:/opt/nifi/nifi-1.9.2/content_repository
- db:/opt/nifi/nifi-1.9.2/database_repository
- flowfile:/opt/nifi/nifi-1.9.2/flowfile_repository
- provenance:/opt/nifi/nifi-1.9.2/provenance_repository
- logs:/opt/nifi/nifi-1.9.2/logs
- data:/opt/nifi/nifi-1.9.2/data
extra_hosts:
- nifi.at:159.69.214.42
networks:
efactory-network:
external:
name: security-network
volumes:
conf:
content:
db:
flowfile:
provenance:
logs:
state:
data:
I persisted data with docker volumes. So state of the cluster should be persisted on a docker-compose restart . I think it's persisted but giving the below error
java.net.UnknownHostException: ffcca3db4879
I will be much grateful if someone can help me on this
Can you add on your nifi:
depends_on:
- zookeeper
I am trying to set up auto builds using docker cloud/docker hub. It is always looking for Dockerfile when I have a docker-compose.yml. I am unable to find any option to change this. I am wondering whether this isn't possible or am I missing something?
This is my docker-compose.yml
version: '3'
services:
reverse-proxy:
image: traefik
ports:
- "80:80"
- "443:443"
- "${TRAEFIK_DASHBOARD_PORT}:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik/traefik.toml:/etc/traefik/traefik.toml
- ./traefik/certs/journal.crt:/certs/journal.crt
- ./traefik/certs/journal.key:/certs/journal.key
networks:
- web
prisma:
image: prismagraphql/prisma:1.8
restart: always
ports:
- "${PRISMA_PORT}"
networks:
- web
environment:
PRISMA_CONFIG: |
port: ${PRISMA_PORT}
managementApiSecret: ${PRISMA_MANAGEMENT_API_SECRET}
databases:
default:
connector: postgres
host: ${PRISMA_DB_HOST}
port: ${PRISMA_DB_PORT}
database: ${PRISMA_DB}
user: ${PRISMA_DB_USER}
password: ${PRISMA_DB_PASSWORD}
migrations: ${PRISMA_ENABLE_MIGRATION}
graphql-server:
build:
context: ./graphql-server/
args:
- PORT=${GRAPHQL_SERVER_PORT}
networks:
- web
ports:
- "${GRAPHQL_SERVER_PORT}"
volumes:
- ./graphql-server:/usr/src/app
depends_on:
- prisma
command: ["./wait-for-it.sh", "prisma:${PRISMA_PORT}", "--", "./bootstrap.sh"]
environment:
- PRISMA_SERVICE_NAME=prisma
- PRISMA_PORT
- GRAPHQL_SERVER_PORT
- APOLLO_ENGINE_KEY
- PRISMA_ENDPOINT
- PRISMA_MANAGEMENT_API_SECRET
labels:
- "traefik.backend=graphql"
- "traefik.frontend.rule=Host:api.journal.com"
- "traefik.enable=true"
- "traefik.port=8080"
- "traefik.docker.network=web"
react-client:
build:
context: ./react-client/
args:
- PORT=${REACT_CLIENT_PORT}
ports:
- "${REACT_CLIENT_PORT}"
volumes:
- ./react-client:/usr/src/app
depends_on:
- graphql-server
environment:
- GRAPHQL_SERVER_PORT
- REACT_CLIENT_PORT
networks:
- web
networks:
web:
external: true
Both docker hub and docker cloud are trying to get only the dockerfile and not docker-compose. I also saw a post mentioning docker-compose should be used only for running and not for building; so I am not sure whether I am doing something wrong.
I'm attempting to run this script in Win10 to configure everything.
All containers except the elastic container are initialized correctly and
Elastic times out and then exits with code 124.
https://imgur.com/a/FO8ckwc (some log outputs)
I'm running this script where I didn't touch anything except the Windows ports (you can see the comments)
https://pastebin.com/7Z8Gnenr
version: '3.1'
# Generated on 23-04-2018
services:
alfresco:
image: openmbeeguest/mms-repo:3.2.4-SNAPSHOT
environment:
CATALINA_OPTS: "-Xmx1G -XX:+UseConcMarkSweepGC"
depends_on:
- postgresql
- activemq
- elastic
networks:
- internal
ports:
- 8080:8080
volumes:
- alf_logs:/usr/local/tomcat/logs
- alf_data:/opt/alf_data
tmpfs:
- /tmp
- /usr/local/tomcat/temp/
- /usr/local/tomcat/work/
solr:
image: openmbeeguest/mms-solr:3.2.4-SNAPSHOT
environment:
CATALINA_OPTS: "-Xmx1G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:G1HeapRegionSize=8m -XX:MaxGCPauseMillis=200"
depends_on:
- alfresco
networks:
- internal
volumes:
- solr_logs:/usr/local/tomcat/logs/
- solr_content_store:/opt/solr/ContentStore
tmpfs:
- /tmp
- /usr/local/tomcat/temp/
- /usr/local/tomcat/work/
activemq:
image: openmbeeguest/mms-activemq:3.2.4-SNAPSHOT
ports:
#I changed these Windows side ports
- 61615:61616
- 61617:61614
- 8162:8161
# ORIGINAL
#- 61616:61616
#- 61614:61614
#- 8161:8161
volumes:
- activemq-data-volume:/data/activemq
- activemq-log-volume:/var/log/activemq
- activemq-conf-volume:/opt/activemq/conf
environment:
- ACTIVEMQ_ADMIN_LOGIN admin
- ACTIVEMQ_ADMIN_PASSWORD admin
networks:
- internal
elastic:
image: openmbeeguest/mms-elastic:3.2.4-SNAPSHOT
environment:
CLEAN: 'false'
ports:
- 9200:9200
volumes:
- elastic-data-volume:/usr/share/elasticsearch/data
networks:
- internal
postgresql:
image: openmbeeguest/mms-postgres:3.2.4-SNAPSHOT
volumes:
- pgsql_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=alfresco
- POSTGRES_PASSWORD=alfresco
- POSTGRES_DB=alfresco
networks:
- internal
volumes:
alf_logs:
alf_data:
solr_logs:
solr_content_store:
pgsql_data:
activemq-data-volume:
activemq-log-volume:
activemq-conf-volume:
elastic-data-volume:
nginx-external-volume:
networks:
internal:
Any help would be greatly appreciated!
Do you have the logs from the elasticsearch container to share? Without that it's hard to tell why it's exiting.
One thing that's tripped me up repeatedly though is the vm.max_map_count setting - the default in Docker is too low for elasticsearch to function, so it's a good first thing to check.