|
| 1 | +-- |
| 2 | +layout: doc |
| 3 | +title: Running with Docker |
| 4 | +order: 8 |
| 5 | +-- |
| 6 | + |
| 7 | +# Running with Docker |
| 8 | + |
| 9 | +Dovecot CE comes with Docker images published at https://hub.docker.com/r/dovecot/dovecot. |
| 10 | + |
| 11 | +## Minimal setup |
| 12 | + |
| 13 | +To run Dovecot you can start it with |
| 14 | + |
| 15 | +```console |
| 16 | +docker run -p 143:31143 -p 993:31993 dovecot/dovecot:latest |
| 17 | +``` |
| 18 | + |
| 19 | +This will expose IMAP and IMAPS ports, but all data is kept locally. |
| 20 | + |
| 21 | +## Persisting mail data |
| 22 | + |
| 23 | +To persist data, mount volume to `/srv/vmail`. Remember that this needs to be writable to UID 1000 internally. |
| 24 | + |
| 25 | +```console |
| 26 | +docker run -v /srv/vmail:/srv/vmail -p 143:31143 -p 993:31993 dovecot/dovecot:latest |
| 27 | +``` |
| 28 | + |
| 29 | +## Configuring instance |
| 30 | + |
| 31 | + |
| 32 | +These docker images are rootless since v2.4.0. This means they are ran with vmail (UID 1000). |
| 33 | + |
| 34 | +To change configuration, put configuration drop-ins to `/etc/dovecot/conf.d`. |
| 35 | + |
| 36 | +```console |
| 37 | +docker run -v /etc/dovecot-config:/etc/dovecot/conf.d,ro -v /srv/vmail:/srv/vmail -p 143:31143 -p 993:31993 dovecot/dovecot:latest |
| 38 | +``` |
| 39 | + |
| 40 | +Dovecot uses TLS certificates from `/etc/dovecot/ssl` directory. The full chain certificate name is expected to be `tls.crt`, and key file `tls.key`. |
| 41 | + |
| 42 | +POP3 service is not enabled by default, if you need pop3, place a pop3.conf drop-in to conf.d: |
| 43 | + |
| 44 | +``` |
| 45 | +protocols { |
| 46 | + pop3 = yes |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +By default imap, submission, lmtp and sieve protocols are enabled. |
| 51 | + |
| 52 | +## Listening ports |
| 53 | + |
| 54 | +Since v2.4.1 ports are exposed as non-privileged ports. You need to map these |
| 55 | +to the ports that you need. |
| 56 | + |
| 57 | +### Exposed protocols |
| 58 | + |
| 59 | +| Protocol | Port | |
| 60 | +| ----------- | ----- | |
| 61 | +| imap | 31143 | |
| 62 | +| imaps | 31993 | |
| 63 | +| pop3 | 31110 | |
| 64 | +| pop3s | 31990 | |
| 65 | +| submissions | 31465 | |
| 66 | +| submission | 31587 | |
| 67 | +| lmtps | 31024 | |
| 68 | +| managesieve | 34190 | |
| 69 | +| HTTP API | 8080 | |
| 70 | +| Metrics | 9090 | |
| 71 | + |
| 72 | +## Running read-only |
| 73 | + |
| 74 | +To run the system fully read-only, use |
| 75 | + |
| 76 | +```console |
| 77 | +docker run --read-only --tmpfs /tmp --tmpfs /run/dovecot -v /srv/vmail:/srv/vmail --rm -it dovecot/dovecot:latest |
| 78 | +``` |
| 79 | + |
| 80 | +Dovecot will need write permissions to `/tmp`, `/run` and persistent mail storage at `/srv/vmail`. |
| 81 | + |
| 82 | +## Running without Linux capabilities |
| 83 | + |
| 84 | +By default, Dovecot needs `CAP_SYS_CHROOT` capability. To remove this requirements, you can prevent chrooting |
| 85 | +by placing no-chroot.conf to drop-in directory: |
| 86 | + |
| 87 | +``` |
| 88 | +service submission-login { |
| 89 | + chroot = |
| 90 | +} |
| 91 | +service imap-login { |
| 92 | + chroot = |
| 93 | +} |
| 94 | +service pop3-login { |
| 95 | + chroot = |
| 96 | +} |
| 97 | +service managesieve-login { |
| 98 | + chroot = |
| 99 | +} |
| 100 | +service imap-urlauth-login { |
| 101 | + chroot = |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +and run Dovecot using |
| 106 | + |
| 107 | +```console |
| 108 | +docker run -v /etc/dovecot-config:/etc/dovecot/conf.d,ro --security-opt "no-new-privileges" --rm -it dovecot/dovecot:latest |
| 109 | +``` |
0 commit comments