Create the network
docker network create mongo-network
docker network ls
Run Mongo container:
docker run \
-p 27017:27017 -d \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=password \
--name mongodb \
--network mongo-network mongo
Check Mongo container logs:
docker ps
docker logs 616e8b
Run Mongo Express container:
docker run -d \
-p 8081:8081 \
-e ME_CONFIG_MONGODB_ADMINUSERNAME=admin \
-e ME_CONFIG_MONGODB_ADMINPASSWORD=password \
--network mongo-network \
--name mongo-express \
-e ME_CONFIG_MONGODB_SERVER=mongodb mongo-express
Check and tail Mongo Express container logs
docker ps
docker logs bd9f59
docker logs bd9f59 -f