|
| 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 | +``` |
| 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 | +``` |
| 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 | +``` |
| 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 |
| 43 | +need pop3, place a pop3.conf drop-in to conf.d: |
| 44 | + |
| 45 | +``` |
| 46 | +protocols { |
| 47 | + pop3 = yes |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +By default imap, submission, lmtp and sieve protocols are enabled. |
| 52 | + |
| 53 | +## Listening ports |
| 54 | + |
| 55 | +Since v2.4.1 ports are exposed as non-privileged ports. You need to map these |
| 56 | +to the ports that you need. |
| 57 | + |
| 58 | +### Exposed protocols |
| 59 | + |
| 60 | +| Protocol | Port | |
| 61 | +| ----------- | ----- | |
| 62 | +| imap | 31143 | |
| 63 | +| imaps | 31993 | |
| 64 | +| pop3 | 31110 | |
| 65 | +| pop3s | 31990 | |
| 66 | +| submissions | 31465 | |
| 67 | +| submission | 31587 | |
| 68 | +| lmtps | 31024 | |
| 69 | +| managesieve | 34190 | |
| 70 | +| HTTP API | 8080 | |
| 71 | +| Metrics | 9090 | |
| 72 | + |
| 73 | +## Running read-only |
| 74 | + |
| 75 | +To run the system fully read-only, use |
| 76 | + |
| 77 | +``` |
| 78 | +docker run --read-only --tmpfs /tmp --tmpfs /run/dovecot -v /srv/vmail:/srv/vmail --rm -it dovecot/dovecot:latest |
| 79 | +``` |
| 80 | + |
| 81 | +Dovecot will need write permissions to `/tmp`, `/run` and persistent mail storage at `/srv/vmail`. |
| 82 | + |
| 83 | +## Running without capabilities |
| 84 | + |
| 85 | +If you do not want to have any capabilities, you need to disable chrooting. |
| 86 | + |
| 87 | +You can disable this with following config drop-in: |
| 88 | + |
| 89 | +``` |
| 90 | +service submission-login { |
| 91 | + chroot = |
| 92 | +} |
| 93 | +service imap-login { |
| 94 | + chroot = |
| 95 | +} |
| 96 | +service pop3-login { |
| 97 | + chroot = |
| 98 | +} |
| 99 | +service managesieve-login { |
| 100 | + chroot = |
| 101 | +} |
| 102 | +service imap-urlauth-login { |
| 103 | + chroot = |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +and run Dovecot using |
| 108 | + |
| 109 | +``` |
| 110 | +docker run -v /etc/dovecot-config:/etc/dovecot/conf.d,ro --security-opt "no-new-privileges" --rm -it dovecot/dovecot:latest |
| 111 | +``` |
0 commit comments