I am utterly confused by the compose instructions.
scyto opened this issue · 3 comments
I am a little confused by the instructions and have been unable to get this working. I am unclear if i have hit an issue, didn't read something i should have (like manually creating databases and users)?
I am trying to deploy in a swarm using mongodb, i am unclear if mongodb is in the docker image or not?
I have tried both of the following:
- assuming mongodb is in the image
- assuming i need separate mongodb
(note i have never used mongodb before)
for approach #1 above
panic: failed to load storage engine: no reachable servers
as such i believe there to be no mondodb server running in the container
for approach #2 above mycompose is further below, when swirl tries to connect to the mongodb it results in this if the db path ends in /swirl
panic: failed to load storage engine: server returned error on SASL authentication step: Authentication failed.
if it doesn't end in /swirl i get
panic: failed to load storage engine: server returned error on SASL authentication step: BSON field 'saslContinue.mechanism' is an unknown field.
compose file:
version: '3.8'
services:
swirl:
image: cuigh/swirl
environment:
DB_TYPE: mongo
DB_ADDRESS: mongodb://mongoroot:password@mongodb:27017/swirl
DOCKER_ENDPOINT: tcp://swirl_manager_agent:2375
AGENTS: swirl_manager_agent,swirl_worker_agent
ports:
- 8001:8001
deploy:
replicas: 1
placement:
constraints: [ node.role == worker ]
manager_agent:
image: cuigh/socat
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
mode: global
placement:
constraints: [ node.role == manager ]
worker_agent:
image: cuigh/socat
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
mode: global
placement:
constraints: [ node.role == worker ]
mongodb:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: mongoroot
MONGO_INITDB_ROOT_PASSWORD: password
mongo-express:
image: mongo-express
restart: always
ports:
- 7081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: mongoroot
ME_CONFIG_MONGODB_ADMINPASSWORD: password
ME_CONFIG_MONGODB_URL: mongodb://mongoroot:password@mongodb:27017/
note my mongo-express service connects with no issues to the database.
For approach 2, DB_ADDRESS should be: mongodb://mongoroot:password@swirl_mongodb:27017/swirl. (Assuming compose name is swirl)
Thanks for the reply.
Do you mean approach two? There is only a service called mongodb in approach two - your reference docker compose has no mongodb service. I will take this as confirmation that your docs assume a pre-setup mongodb - might be good to actually call that out in the docs. If i end up with swirl as a permanent part of my setup i can help do docs.
You seem to be unaware that in a swarm stack you can call the service just by the service name - I assure you one can ping mongodb
from any container node in the stack just fine - it doesn't need the stackname_
prefix :-) and defining a network is redundant unless the network is used by another stack, but then it would need to be created as external.
It still appears on the surface to to me swirl doesn't support the latest auth mechanisms correctly in mongo - but i am making a lot of un-educated guesses to get to that conclusion! Again maybe its because i didn't do something i should on mongodb?
I also now realize that without a prometheus setup this is an incomplete solution. TBH the docs are very confusing about what this solution is, what is a pre-req. I think that's fine if you purely built this for yourself tho :-) - for someone who is coming from deep docker knowledge but no knowledge on what Prometheus or cadvisor are I had the wrong impression that swirl would give me out of the box stats (mostly the fault of the sites that linked me here), for example why would i need to go docker > cadvisor > prometheus when docker has native support / exporters for prometheus?
tl;dr This modified version below got me up and running to see what swirl is all about with the downside there is no no auth support. (and off to learn prometheus and i guess cadvisor at the weekend)
version: '3.8'
services:
swirl:
image: cuigh/swirl
environment:
DB_TYPE: mongo
DB_ADDRESS: mongodb://mongodb:27017/swirl
DOCKER_ENDPOINT: tcp://swirl_manager_agent:2375
AGENTS: swirl_manager_agent,swirl_worker_agent
ports:
- 8001:8001
deploy:
replicas: 1
placement:
constraints: [ node.role == worker ]
manager_agent:
image: cuigh/socat
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
mode: global
placement:
constraints: [ node.role == manager ]
worker_agent:
image: cuigh/socat
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
mode: global
placement:
constraints: [ node.role == worker ]
mongodb:
image: mongo
restart: always
# environment:
# MONGO_INITDB_ROOT_USERNAME: mongoroot
# MONGO_INITDB_ROOT_PASSWORD: password
mongo-express:
image: mongo-express
restart: always
ports:
- 7081:8081
environment:
# ME_CONFIG_MONGODB_ADMINUSERNAME: mongoroot
# ME_CONFIG_MONGODB_ADMINPASSWORD: password
ME_CONFIG_MONGODB_URL: mongodb://mongodb:27017/
BTW nice job on the image creation, i crawled over your dockerfile, love your keep it simple approach
Thank you for your advice. You are right, Swirl's document should really have a pre requirements chapter. I will add this part later and provide a composite file out of the box.