Self-Hosting Roundcube with Docker Compose

What Is Roundcube?

Roundcube is the most popular open-source webmail client. It connects to any IMAP mail server and provides a clean, modern web interface for reading and composing email. Drag-and-drop attachments, address book with LDAP support, spell checking, threaded conversations, PGP encryption via plugins, and a responsive interface that works on mobile. If you’re running your own mail server with Mailcow, Mailu, or Docker Mailserver, Roundcube is the webmail frontend you pair with it.

Official site: roundcube.net | GitHub

Prerequisites

  • A Linux server (Ubuntu 22.04+ recommended)
  • Docker and Docker Compose installed (guide)
  • An existing IMAP/SMTP mail server (Roundcube is a client, not a server)
  • 500 MB of free disk space
  • 256 MB of RAM minimum
  • A domain name (recommended)

Docker Compose Configuration

This configuration uses the Apache variant with MySQL for production:

services:
  roundcube:
    image: roundcube/roundcubemail:1.6.13-apache
    container_name: roundcube
    restart: unless-stopped
    ports:
      - "9001:80"
    environment:
      - ROUNDCUBEMAIL_DB_TYPE=mysql
      - ROUNDCUBEMAIL_DB_HOST=roundcube-db
      - ROUNDCUBEMAIL_DB_NAME=roundcube
      - ROUNDCUBEMAIL_DB_USER=roundcube
      - ROUNDCUBEMAIL_DB_PASSWORD=changeme_db
      - ROUNDCUBEMAIL_DEFAULT_HOST=tls://mail.example.com
      - ROUNDCUBEMAIL_SMTP_SERVER=tls://mail.example.com
      - ROUNDCUBEMAIL_SMTP_PORT=587
      - ROUNDCUBEMAIL_SKIN=elastic
      - ROUNDCUBEMAIL_UPLOAD_MAX_FILESIZE=25M
    volumes:
      - roundcube-www:/var/www/html
    depends_on:
      roundcube-db:
        condition: service_healthy
    networks:
      - roundcube-net

  roundcube-db:
    image: mysql:8.4
    container_name: roundcube-db
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=changeme_root
      - MYSQL_DATABASE=roundcube
      - MYSQL_USER=roundcube
      - MYSQL_PASSWORD=changeme_db
    volumes:
      - roundcube-dbdata:/var/lib/mysql
    networks:
      - roundcube-net
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  roundcube-www:
  roundcube-dbdata:

networks:
  roundcube-net:

Change these values before starting:

  • ROUNDCUBEMAIL_DB_PASSWORD and MYSQL_PASSWORD — set to a strong password (must match)
  • MYSQL_ROOT_PASSWORD — set to a different strong password
  • ROUNDCUBEMAIL_DEFAULT_HOST — your IMAP server hostname (use tls:// for encrypted connections)
  • ROUNDCUBEMAIL_SMTP_SERVER — your SMTP server hostname

Start the stack:

docker compose up -d

Initial Setup

Access Roundcube at http://your-server-ip:9001. Log in with your email credentials — Roundcube authenticates against the IMAP server you configured.

No admin setup wizard needed. If the IMAP/SMTP settings are correct, you can log in immediately with any valid email account on that server.

Configuration

Connecting to Your Mail Server

The two critical environment variables:

VariableExampleDescription
ROUNDCUBEMAIL_DEFAULT_HOSTtls://mail.example.comIMAP server. Use tls:// for STARTTLS on port 143, ssl:// for implicit TLS on port 993
ROUNDCUBEMAIL_SMTP_SERVERtls://mail.example.comSMTP server. Use tls:// for STARTTLS on port 587, ssl:// for implicit TLS on port 465

If your IMAP/SMTP server uses non-standard ports:

- ROUNDCUBEMAIL_DEFAULT_PORT=993
- ROUNDCUBEMAIL_SMTP_PORT=465

Using with Self-Hosted Mail Servers

Mail ServerIMAP HostSMTP Host
Mailcowtls://mail.example.comtls://mail.example.com
Mailussl://imap.mailu (internal)ssl://smtp.mailu (internal)
Docker Mailservertls://mail.example.comtls://mail.example.com
Stalwarttls://mail.example.comtls://mail.example.com

When running Roundcube on the same Docker network as your mail server, use internal hostnames and skip TLS.

Lightweight Setup with SQLite

For personal use or testing, skip MySQL and use SQLite:

services:
  roundcube:
    image: roundcube/roundcubemail:1.6.13-apache
    container_name: roundcube
    restart: unless-stopped
    ports:
      - "9001:80"
    environment:
      - ROUNDCUBEMAIL_DEFAULT_HOST=tls://mail.example.com
      - ROUNDCUBEMAIL_SMTP_SERVER=tls://mail.example.com
      - ROUNDCUBEMAIL_SKIN=elastic
    volumes:
      - roundcube-www:/var/www/html
      - roundcube-db:/var/roundcube/db

volumes:
  roundcube-www:
  roundcube-db:

Plugins

Roundcube has a rich plugin ecosystem. Enable plugins via the ROUNDCUBEMAIL_PLUGINS environment variable:

- ROUNDCUBEMAIL_PLUGINS=archive,zipdownload,managesieve,markasjunk

Popular plugins:

  • archive — Archive button for organizing mail
  • zipdownload — Download multiple attachments as ZIP
  • managesieve — Server-side mail filtering rules (requires Sieve on your IMAP server)
  • markasjunk — Report spam to the mail server
  • enigma — PGP encryption and signing

Reverse Proxy

For HTTPS access, see Reverse Proxy Setup. No special headers required.

Backup

Back up the MySQL database and the roundcube-www volume (custom configs, plugins):

docker compose exec roundcube-db mysqldump -u roundcube -p roundcube > roundcube-backup-$(date +%Y%m%d).sql

Email data lives on your IMAP server, not in Roundcube. Roundcube only stores preferences, contacts, and cached data.

For a full backup strategy, see Backup Strategy.

Troubleshooting

”Connection to Storage Server Failed”

Symptom: Login shows “Connection to storage server failed” error.

Fix: The IMAP server is unreachable. Verify ROUNDCUBEMAIL_DEFAULT_HOST is correct. Test connectivity:

docker compose exec roundcube bash -c "echo 'test' | openssl s_client -connect mail.example.com:993 -quiet"

If using internal Docker networking, ensure both containers are on the same network.

”SMTP Error: Authentication Failed”

Symptom: Can receive but not send email.

Fix: SMTP authentication uses the same credentials as IMAP login. Verify ROUNDCUBEMAIL_SMTP_SERVER and port are correct. Some servers use different ports for submission (587) vs relay (25).

Attachments Too Large

Symptom: Cannot upload attachments over a few MB.

Fix: Increase the upload limit:

- ROUNDCUBEMAIL_UPLOAD_MAX_FILESIZE=50M

Also check your mail server’s message size limit.

Resource Requirements

  • RAM: ~100 MB (Apache + PHP)
  • CPU: Minimal — webmail is lightweight
  • Disk: ~200 MB for the application, database grows slowly with contacts and preferences

Verdict

Roundcube is the go-to webmail client for self-hosted mail servers. The Elastic theme is clean and responsive, the plugin system is mature, and it connects to any standard IMAP server. Setup takes minutes if you already have a mail server running. The main limitation is that it’s a traditional webmail client — if you want a Gmail-like experience with conversation threading and smart categorization, you’ll find it basic. For most self-hosters who just need web access to their email, Roundcube does the job well. Snappymail is a lighter, faster alternative if Roundcube feels heavy.

Comments