This is a Docker image for an OpenDKIM milter server. The project is part of the docker-mailserver project but can run separately without the other components. However, a database server is always required to store keys and configuration.
Related images:
The following versions are available from DockerHub. The image tag matches the Postfix version.
docker-mailserver-opendkim is licensed under GNU LGPL 3.0. As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
The following components must be available at runtime:
mailserver-opendkim requires various environment variables to be set. The container startup will fail when the setup is incomplete.
| Variable | Description | Default Value |
|---|---|---|
DKIM_SETUP_PASS | The password of the database administrator (root). This value is required for the initial bootstrap only in order to setup the database structure. It can and shall be removed after successful setup. | |
DKIM_DB_HOST | The hostname or IP address of the database server | localhost |
DKIM_DB_USER | The name of the database user. Attention! You shall not use an administrator account. | opendkim |
DKIM_DB_PASS | The password of the database user | opendkim |
DKIM_DB_NAME | The name of the database | opendkim |
DKIM_DOMAIN | The first and primary mail domain of this server. | localdomain |
DKIM_PORT | The milter port the docker image shall offer its service | 41001 |
docker-mailserver-opendkim exposes 2 ports by default:
The main mailserver project has examples of container configurations:
Once you have started your OpenDKIM container successfully, it is now time to create your DKIM signing keys for each domain. This is what you need to do:
/bin/bash interactively on the container.DOMAIN perform the following steps:
Create a temporary directory: mkdir /etc/opendkim/keys/$DOMAIN
Create the actual key: opendkim-genkey -b 2048 -d $DOMAIN -D /etc/opendkim/keys/$DOMAIN -s default -v. You will find public and private key in the temporary directory.
Insert public and private key into your database by signing in: mysql -u opendkim -p opendkim and enter your database password.
Then enter these SQL statement and hit enter for each of them:
INSERT INTO `dkim_keys` (`domain_name`, `selector`, `private_key`, `public_key`) VALUES ('$DOMAIN', 'default', '-----BEGIN RSA PRIVATE KEY-----\r\n***$YOUR_PRIVATE_KEY*** \r\n-----END RSA PRIVATE KEY-----', '-----BEGIN RSA PUBLIC KEY-----\r\n***$YOUR_PUBLIC_KEY***-----END RSA PUBLIC KEY-----');`
SELECT `id` FROM `dkim_keys` WHERE `domain_name` = '$DOMAIN';
INSERT INTO `dkim_signing` (`author`, `dkim_id`) VALUES ('$DOMAIN', $KEYID_FROM_SELECT);
INSERT INTO `ignore_list` (`hostname`) VALUES ('*@$DOMAIN');
INSERT INTO `internal_hosts` (`hostname`) VALUES ('*@$DOMAIN');
Insert the Public Key as described by step 2 output into your DNS TXT record for the domain. It can look like this:
v=DKIM1; h=sha256; k=rsa; p=***PUBLIC_KEY_WITHOUT_SPACE_OR_NEWLINE***
The TXT record needs to be named default._domainkey.$DOMAIN - the default can be varied when using a different value in SQL statement in step 3. This would enable
you to use different keys e.g. for subdomains and individual mail addresses. You would need to change the SQL commands accordingly (Table dkim_keys decides
which key will be used. You can use full mail addresses in column author then.)
You can further customize the OpenDKIM configuration files. Please follow these instructions:
/usr/local/mailserver/templates folder for already existing customizations./usr/local/mailserver/templates by using volume mappings./usr/local/mailserver/reset-server.sh. Then restart again.Here are some useful links that help you to test whether your DKIM setup works as intended:
This Docker image is mature in its DKIM signing and verification feature. However, creation of DKIM keys is still cumbersome and needs to be improved. A web page service is planned to ease that step.
Report a bug, request an enhancement or pull request at the GitHub Issue Tracker. Make sure you have checked out the Contribution Guideline
Content type
Image
Digest
Size
171 MB
Last updated
about 5 years ago
docker pull j1cs/opendkim