This document provides detailed instructions for deploying and managing the Docker Mailserver GUI using Docker.
- Docker Engine (version 19.03.0+)
- Running docker-mailserver container
- Docker socket access (/var/run/docker.sock)
- Docker Compose (version 1.27.0+ - only if using Option 2)
Both deployment options use the same environment variables:
DOCKER_CONTAINER: The name of your docker-mailserver container (required)PORT: Internal port for the Node.js server (defaults to 3001)NODE_ENV: Node.js environment (defaults to production)
You can deploy Docker Mailserver GUI in two ways:
- Option 1: Using pre-built Docker Hub image - Easiest method, no build required
- Option 2: Building locally with Docker Compose - For customization or development
Each option is detailed in the sections below.
docker-mailserver-GUI/
├── backend/ # Backend API
├── frontend/ # Frontend React app
├── docker/ # Docker configuration files
│ ├── nginx.conf # Nginx configuration
│ └── start.sh # Container startup script
├── Dockerfile # Docker image configuration
├── docker-compose.yml # Docker Compose configuration
└── README.docker.md # Docker setup documentation
The application is available as a pre-built Docker image on Docker Hub:
docker run -d \
--name mailserver-gui \
-p 80:80 \
-e DOCKER_CONTAINER=mailserver \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
dunajdev/docker-mailserver-gui:latestWhere:
mailserveris the name of your docker-mailserver container- Port 80 is mapped to your host
For more information about the Docker Hub image, visit: https://hub.docker.com/r/dunajdev/docker-mailserver-gui
Before building the application, adjust the docker-compose.yml file to match your docker-mailserver setup:
- Update the
DOCKER_CONTAINERenvironment variable to match your docker-mailserver container name
Example:
environment:
- DOCKER_CONTAINER=mail-server # Your docker-mailserver container nameThat's it! Since we're using Docker API via the socket, no network configuration is needed. The application will communicate with docker-mailserver through the Docker daemon on the host.
To build and start the application:
docker-compose up -dThis will:
- Build the Docker image that includes both frontend and backend
- Start the container in detached mode
- Map port 80 for the web interface
Once the container is running, you can access the web interface at:
http://localhost
To stop the application:
docker-compose downTo view logs from the container:
docker-compose logs -f mailserver-guiTo update the application after making changes:
docker-compose down
docker-compose build
docker-compose up -dThe Docker setup uses a multi-stage build process:
- First stage builds the React frontend
- Second stage prepares the Node.js backend
- Final stage combines both into a single image with Nginx and Docker client
When the container starts:
- The backend Node.js server runs on port 3001 inside the container
- Nginx serves the frontend static files
- Nginx proxies API requests (/api/*) to the Node.js backend
- The backend communicates with your docker-mailserver container via Docker API
The application uses Docker API directly (via the dockerode library) to:
- Execute commands in the docker-mailserver container
- Check the container status and resource usage
- All operations are performed through the Docker socket (/var/run/docker.sock)
Unlike a traditional approach where containers need to be on the same network to communicate, using the Docker API through the socket means:
- The application talks to the Docker daemon on the host
- The Docker daemon then communicates with the docker-mailserver container
- No direct network connection between containers is needed
- This simplifies configuration and deployment
- Ensure the docker-mailserver container is running
- Check that the container name matches the
DOCKER_CONTAINERenvironment variable - Check that the
/var/run/docker.sockvolume is correctly mounted - Verify that your host user has permissions to access the Docker socket
- Check the container logs:
docker-compose logs mailserver-gui - Verify that the Nginx configuration correctly proxies to the backend
- Ensure the backend can start properly
- Check that the Docker socket is correctly mounted in the container
- Ensure your user has permissions to access the Docker socket
- Verify that the Docker client is installed in the container
- The container has access to the Docker socket, which is a security risk. Make sure to restrict access to the container.
- Consider setting up HTTPS for production deployments (you can modify the nginx.conf)
- Add authentication to the web interface for production use