digimach/acme.sh Docker Image
Docker化的ACME Shell脚本(acme.sh),注重兼容性与安全性,支持多架构和多基础操作系统,可作为非root用户运行,并提供自动证书续期守护进程。
ACME Shell script: acme.sh Docker image
https://github.com/acmesh-official/acme.sh available in Docker with compatibility and security in mind. This container holds the official upstream acme.sh artifacts.
Features:
- Multiple architectures
- Multiple base operating systems
- Handles running as a non-root user
- Upstream OS patches applied to
latesttag at build time - Renewal daemon to check and renew certificates automatically
- Usage
- acme.sh Command Line
- Renewal Daemon
- Parameters
- General
- Renewal Daemon
- Advanced
- User / Group Identifiers
- Examples
- Running as root user
- Fulfilling a Certificate Signing Request (CSR)
- Running Arbitary Commands
- Published Images
- Base Images and Architectures
Usage
acme.sh Command Line
docker run --interactive \ --rm \ --tty \ --env PUID=1001 \ --env PGUID=1001 \ --env LE_CONFIG_HOME=/srv/acmesh/config \ --env LE_CERT_HOME=/srv/acmesh/cert-home \ --volume /srv/acmesh/config:/srv/acmesh/config \ --volume /srv/acmesh/cert-home:/srv/acmesh/cert-home \ digimach/acme.sh:latest \ acme.sh <acme.sh args>
Renewal Daemon
Use the same parameters and their value as acme.sh Command Line with the additional parameters shown below.
docker run --interactive \ --detach \ --name acmesh-renewal-daemon \ --env PUID=1001 \ --env PGUID=1001 \ --env LE_CONFIG_HOME=/srv/acmesh/config \ --env LE_CERT_HOME=/srv/acmesh/cert-home \ --env LE_LOG_DIR=/srv/acmesh/logs \ --env ACMESH_DAEMON=1 \ --env RENEWAL_CHECK_FREQUENCY=1h \ --volume /srv/acmesh/config:/srv/acmesh/config \ --volume /srv/acmesh/cert-home:/srv/acmesh/cert-home \ --volume /srv/acmesh/logs:/srv/acmesh/logs \ digimach/acme.sh:latest
It is important to kill the container running the renewal daemon gracefully.
docker kill -s SIGTERM acmesh-renewal-daemon
The above will kill the daemon if it is just waiting for the next renewal check and let it finish the renewal check and issue process if its already running.
Parameters
General
The acme.sh container can be configured at run time by passing parameters.
| Parameters | Function |
|---|---|
-e LE_CONFIG_HOME=/acmesh/config | Sets the directory in which acme.sh will store configuration. |
-e LE_CERT_HOME=/acmesh/cert-home | Sets the directory which stores certificates and configuration related to signing of certificates. This directory if separate from other directories used by acme.sh can be used to distribute signed certificates if there are no private keys. |
-e PUID=1001 | See User/Group settings |
-e PGID=1001 | See User/Group settings |
-v /acmesh/config | acme.sh config goes here as defined by LE_CONFIG_HOME variable. |
-v /acmesh/cert-home | acme.sh stores the certificates here as defined by LE_CERT_HOME variable. |
Renewal Daemon
These parameters are in addition to the above parameters and only apply to the operations of renewal daemon.
| Parameters | Function |
|---|---|
-e ACMESH_DAEMON=0 | If launching the container as a renewal daemon set this to 1. |
-e RENEWAL_CHECK_FREQUENCY=1h | The frequency with which renewal checks should be performed. The unit of time can be provided eg 300s, 60m, 2h, 1d |
-e LE_LOG_DIR=/acmesh/logs | Set the directory where logs are stored for the acme.sh renewal daemon. |
-e S6_LOGGING_SCRIPT=n30 s10000000 S15000000 T !'gzip -nq9' | Configure parameter for https://skarnet.org/software/s6/s6-log.html that defines what to log, where, and how. |
-v /acmesh/logs | The renewal daemon stores the logs in this directory defined by LE_LOG_DIR variable. |
Advanced
These are advanced parameters that are only to be used when needed.
| Parameters | Function |
|---|---|
-e LE_WORKING_DIR=/usr/lib/acmesh | Set the directory in which acme.sh is installed and also used by it to look for deploy, dnsapi and notify hooks. The container already has acme.sh installed in the directory at build time which is set to /usr/lib/acmesh by default. |
-e AUTO_UPGRADE=0 | If set to 1 acme.sh will upgrade itself. It is not recommended to have acme.sh auto upgrade itself. Instead, update the container by downloading the appropriate tag eg latest. |
-e S6_BEHAVIOUR_IF_STAGE2_FAILS=2 | Sets how s6 behaves if fix-attrs or cont-init fails. See https://github.com/just-containers/s6-overlay#customizing-s6-behaviour |
User / Group Identifiers
By default the container runs the command uid1001 and gid:1001. When mounting volumes (using -v/--volume) permission issues can arrise. This can be fixed by having the container execute the command as a user who has read and write permisions on the mounted host volume.
Examples
The container is built to allow a drop in replacement for acme.sh command running on
the host. The following two commands are equivalent, one running on the host with
acme.sh installed vs the other running from within the container - both running as uid:1001 and gid:1001:
LE_WORKING_DIR=/usr/lib/acmesh \ LE_CONFIG_HOME=/srv/acmesh/config \ LE_CERT_HOME=/srv/acmesh/cert-home \ acme.sh <acme.sh args>
docker run --interactive \ --rm \ --tty \ --env PUID=1001 \ --env PGUID=1001 \ --env LE_CONFIG_HOME=/srv/acmesh/config \ --env LE_CERT_HOME=/srv/acmesh/cert-home \ --name acmesh \ --volume /srv/acmesh:/srv/acmesh/ \ digimach/acme.sh:latest \ acme.sh \ <acme.sh args>
Running as root user
To overide the default behaviour of the container to run as a limited user set the PUID and GUID variable as 0.
This is not recomended and should be avoided at all cost.
docker run --interactive \ --rm \ --tty \ --env PUID=0 \ --env PGUID=0 \ --env LE_CONFIG_HOME=/srv/acmesh/config \ --env LE_CERT_HOME=/srv/acmesh/cert-home \ --name acmesh \ --volume /srv/acmesh:/srv/acmesh/ \ digimach/acme.sh:latest \ acme.sh \ <acme.sh args>
Fulfilling a Certificate Signing Request (CSR)
This is beyond the scope of this guide, but putting an example of fulfilling a CSR and performing the domain validation via DNS.
In the example below, the CSR is placed in /srv/acmesh/foo.mydomain.com.csr which will be copied over to /srv/acmesh/cert-home/foo.mydomain.com/foo.mydomain.com.csr when the --signcsr command is issued after which the CSR can be removed from /srv/acmesh/foo.mydomain.com.csr
The example also makes use of --renew-hook which will run the script after a successful issue/renewal of the certificate.
docker run --interactive \ --rm \ --tty \ --env LE_CONFIG_HOME=/srv/acmesh/config \ --env LE_CERT_HOME=/srv/acmesh/cert-home \ --user <uid>:<gid> \ --volume /srv/acmesh:/srv/acmesh \ digimach/acme.sh:latest \ acme.sh \ --signcsr \ --csr /srv/acmesh/foo.mydomain.com.csr \ --dns dns_clouddns \ --challenge-alias foo.mydomain.com \ --renew-hook /srv/acmesh/config/renew-hook.sh
Running Arbitary Commands
docker run --interactive \ --rm \ --tty \ --user <uid>:<gid> \ --volume /srv/acmesh:/srv/acmesh \ digimach/acme.sh:latest \ ls -alrt /srv/acmesh
Published Images
To simplify tagging scheme, the following nomenclature is applied to all published tags. Depending on the end use case, you can choose the appropriate tag.
For clarification purposes, the term latest refers to latest at build time and if the tag is not dated, it will be kept up to date.
If a base OS has multiple versions, every attempt will be made to keep using the latest stable OS version. Build and support for older version maybe dropped if the upstream OS does not provide any support. Please refer to the base OS release cycles for more information.
| Tag | Purpose | Example | Update Frequency | Branch |
|---|---|---|---|---|
| latest | The latest acme.sh with up to date OS patches based on latest Ubuntu base image. | latest | Daily | |
| stable | The latest stable release of acme.sh with up to date OS patches based on latest Ubuntu image. | stable | Daily | |
| <base_os>-latest | The latest release of acme.sh with up to date base OS patches. | * alpinelinux-latest * debian-latest * oraclelinux-latest * ubunut-latest | Daily | |
| <base_os>-<acme.sh-version> | The release of acme.sh as embedded in the tag with up to date OS patches based on latest base OS image. While the acme.sh version will remain static, this image tag will be regularly updated with latest OS patches applied. | * alpinelinux-2.8.8 * debian-2.8.8 * oraclelinux-2.8.8 * ubunut-2.8.8 | Daily | |
| <base_os>-master-<YYYYMMDD> | The latest release of acme.sh at build time with up to date OS patches based on latest base OS image. The image tag is dated for downstream use cases where a static reference is required. Keep in mind, these images do not have OS patches applied regularly nor is acme.sh ever updated. | * alpinelinux-master-20210425 * debian-master-20210425 * oraclelinux-master-20210425 * ubunut-master-20210425 | Once | |
| <base_os>-<acme.sh-version>-<YYYYMMDD> | The release of acme.sh as embedded in the tag with up to date OS patches based on latest base OS image. The image tag is dated for downstream use cases where a static reference is required. Keep in mind, these images do not have OS patches applied regularly nor is acme.sh ever updated. | * alpinelinux-2.8.8-20210425 * debian-2.8.8-20210425 * oraclelinux-2.8.8-20210425 * ubunut-2.8.8-20210425 | Once |
Base Images and Architectures
Every attempt is made to cover popular distributions and architectures in published images. The following table captures what OS, base image tag and architecture are currently published.
| Image OS | Base Image Tag | Archs |
|---|---|---|
| Alpine Linux | latest | linux/arm64/v8, linux/amd64, linux/arm/v6, linux/arm/v7, linux/386, linux/ppc64le, linux/s390x |
| Amazon Linux | latest | linux/arm64/v8, linux/amd64 |
| Oracle Linux | 8-slim | linux/arm64/v8, linux/amd64 |
| Rocky Linux | latest | linux/arm64/v8, linux/amd64 |
| Ubuntu | latest | linux/arm64/v8, linux/amd64, linux/arm/v7, linux/ppc64le, linux/s390x |
镜像拉取方式
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
DockerHub 原生拉取命令
用户好评
来自真实用户的反馈,见证轩辕镜像的优质服务