Mongo Express is a web-based administrative interface for managing MongoDB databases. Mongo Express can be used to create, modify and delete databases, collections, and documents.
This tutorial explains how to install Mongo Express inside a Docker container in the Linux. Commands have been tested on Ubuntu.
Prepare environment
Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.
You also need to have a running MongoDB container. Instructions can be found in the post.
Install Mongo Express
- Host network
Run the following command to create a container for Mongo Express that uses host network:
docker run -d --name=mongo-express --restart=always --network=host \
-e ME_CONFIG_BASICAUTH_USERNAME=admin \
-e ME_CONFIG_BASICAUTH_PASSWORD=pwd123 \
-e ME_CONFIG_MONGODB_ADMINUSERNAME=admin \
-e ME_CONFIG_MONGODB_ADMINPASSWORD=pwd123 \
-e ME_CONFIG_MONGODB_SERVER=127.0.0.1 \
mongo-express
MongoDB container should run on host network as well.
- User-defined bridge network
User-defined bridge network can be used for listening on different port. By default, Mongo Express service is listening on port 8081. It can be changed with -p
option.
docker network create app-net
docker run -d --name=mongo-express --restart=always --network=app-net \
-p 8080:8081 \
-e ME_CONFIG_BASICAUTH_USERNAME=admin \
-e ME_CONFIG_BASICAUTH_PASSWORD=pwd123 \
-e ME_CONFIG_MONGODB_ADMINUSERNAME=admin \
-e ME_CONFIG_MONGODB_ADMINPASSWORD=pwd123 \
-e ME_CONFIG_MONGODB_SERVER=mongodb \
mongo-express
MongoDB container should run on the same user-defined bridge network as well.
Notes:
- Don't forget to change admin password for Mongo Express using
ME_CONFIG_BASICAUTH_PASSWORD
. - Make sure you specified correct MongoDB admin password using
ME_CONFIG_MONGODB_ADMINPASSWORD
. - When user-defined bridge network is used, don't forget to change
ME_CONFIG_MONGODB_SERVER
. It specifies MongoDB container name.
Testing Mongo Express
Open a web browser and go to http://<IP_ADDRESS>:8081
, where <IP_ADDRESS>
is the IP address of the system. Log in to the administrative interface with the admin
username and password.
Uninstall Mongo Express
To completely remove Mongo Express, remove its container:
docker rm --force mongo-express
Remove Mongo Express image:
docker rmi mongo-express
If a user-defined bridge network was created, you can delete it as follows:
docker network rm app-net
Leave a Comment
Cancel reply