Hello all.
I must be doing something wrong, I hope I can get some help here.
I’m trying to migrate from vagrant to docker, and for a legacy project I need a set-up with Apache/PHP/MySQL and MongoDB
I have the DAMP stack working, but the mongo and mongo-express web-client have me boggled.
What I am trying to do:
access mongo on exposed port 27017 using Robo 3T
access mongo-express as alternative to Robo on exposed port 8081
How am I trying to do that:
snippet from docker-compose.yml
mongo:
container_name: mongodb
image: mongo
restart: always
volumes:
- ./.data/mongo:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: fake
MONGO_INITDB_ROOT_PASSWORD: fake
ports:
- 27017:27017
mongoExpress:
image: mongo-express
container_name: me
depends_on:
- mongo
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: fake
ME_CONFIG_MONGODB_ADMINPASSWORD: fake
then open Robo 3T and connect to localhost:27017 or 127.0.0.1:27017, error response:
Cannot connect to the MongoDB at 127.0.0.1:27017.
Error:
Network error while attempting to run command 'saslStart' on host '127.0.0.1:27017'
open localhost:8081
in browser, or 127.0.0.1:8081
, no response
$ curl -I http://localhost:8081
returns: “empty response from server”
docker container ls
reports the containers running and ports exposed.
CONTAINER ID IMAGE <snip> PORTS NAMES
384b91afabe4 docker_web <snip> 0.0.0.0:8000->80/tcp php74
952ad36a4e13 mongo-express <snip> 0.0.0.0:8081->8081/tcp me
8d09f0ba3a45 mongo <snip> 0.0.0.0:27017->27017/tcp mongodb
6274b910d561 mariadb:latest <snip> 0.0.0.0:13306->3306/tcp mariadb
the php74 (web) container is working perfectly, why shouldn’t the mongo and me containers? Also, the mariadb container is working perfectly both from the php74 container and with SequelPro on its exposed port.
I noticed the exposed verses internal port difference (the working ones have different host and client ports and the not working ones have identical ports) so I did already try with alternate ports (27018 for mongo and 8181 for mongoExpress) which did not help.
the mongo data store is getting filled, so I know the software is running, or at least ran once and when I enter the container with docker exec -it mongodb /bin/bash
and ps -A | grep mongo
I see the process running.
As you might suspect, I’m a total noob with Docker but I’m trying to learn. Hopefully anyone can point me to my mistake.
I’m running Docker on a Mac, macOS 10.15, Docker Desktop version 3.4.0, cli version 20.10.7.
Thank you very much in advance!
Remon.