Docker
Building the mimicd image, what it contains and sets, running it, and the Docker Compose file that runs it with PostgreSQL on one host.
The image
mimicd/Dockerfile builds the image from the repository's root, which is
its build context:
docker build -f mimicd/Dockerfile --build-arg MIMIC_BUILD_COMMIT="$(git rev-parse HEAD)" -t mimicd .It builds the document core (Rust) as a static library in a stage of its own, reused while nothing it is built from changes, and links it into the Go binary. The first build takes several minutes; later builds that change only Go code take seconds.
- Contents. A distroless base (CA certificates and the C runtime, no
shell) and
/usr/local/bin/mimicd, its only executable, running as the non-root user 65532. No volume: the process keeps no state. - Entrypoint.
mimicd serve. Arguments you give are its options. - Ports.
7700, the public API, and7702, the operations listener. The image setsMIMIC_LISTEN_OPERATIONS=0.0.0.0:7702so the listener is reachable on the container's addresses. - Health check.
mimicd probe, which asks/readyzon port7702. - Stop. On
SIGTERMthe process hands its partitions over within 20 seconds. Docker's default stop timeout is 10 seconds: give it more (docker run --stop-timeout 30). - Build arguments.
MIMIC_BUILD_COMMITis the commit the binary announces in its version (12 to 64 hexadecimal digits; the image has no git directory to read it from).MIMIC_VERSIONandMIMIC_BUILD_COMMITlabel the image.MIMIC_BUILD_JOBSbounds the build's parallel jobs.
The base images are named by tag. For builds you can reproduce byte for byte, pin them by digest and update the digests deliberately.
A process in a container
docker run -d --name mimicd --stop-timeout 30 \
--cap-drop ALL --security-opt no-new-privileges:true \
-e MIMIC_POSTGRES_URL \
-e MIMIC_BOOTSTRAP_PASSWORD \
-p 127.0.0.1:7700:7700 \
mimicd --bootstrap-admin admin-e NAME without a value passes the variable from your shell, so the
store's URL and the password stay off the command line. The process needs
no capability. Publish plain HTTP on the loopback only, behind a proxy that
terminates TLS, or let the process serve TLS itself (see
Network and TLS).
Run operator commands in the running container, which has the store's URL
in its environment: docker exec mimicd mimicd admin status. docker run
would start another server, since the entrypoint is mimicd serve.
With PostgreSQL, on one host
mimicd/compose.yaml runs mimicd and a vanilla PostgreSQL 18 on one host.
The quickstart walks through it.
- Passwords.
mimicd/.envholdsMIMIC_BOOTSTRAP_PASSWORD(the superuser's) andMIMIC_POSTGRES_PASSWORD(the rolemimicdconnects as), with no defaults: without the second,upstarts nothing; without the first, it starts PostgreSQL and refuses to start the server.MIMIC_BOOTSTRAP_ADMINnames another superuser thanadmin. - The superuser. Created at the first start, from the password handed over as a Compose secret readable by the image's user alone. It is never overwritten: changing the variable later changes nothing, and the server warns of it at each start. To set a password again, see Lost superuser credentials.
- PostgreSQL. The server connects as
mimicd, a role that owns the database and is no superuser, made when PostgreSQL creates its data directory. PostgreSQL's own superuser has no password and signs in only from inside its container (docker compose -f mimicd/compose.yaml exec postgres psql -U postgres -d mimic). PostgreSQL is reachable only on the project's network, keepsfsync,synchronous_commitandfull_page_writeson, and checksums its pages. - Changing a password.
up -drecreates a container whose configuration changed: a newMIMIC_POSTGRES_PASSWORDrecreates both (set it in PostgreSQL first, with\password mimicd, then in.env). After editing.env, runup -d --force-recreate. - Publishing. The API is plain HTTP on
127.0.0.1:7700(MIMIC_PUBLIC_ADDRESS). Never publish it beyond the loopback without a TLS proxy in front: Docker publishes ports with its own packet-filter rules, which bypass host firewalls such as ufw. - Data. In the
postgresvolume.downkeeps it;down -vdeletes it. - PostgreSQL's version. The file runs PostgreSQL 18, whose image keeps
its data under
/var/lib/postgresql/18. Another major version starts an empty cluster beside it, on whichmimicdwould found a new, empty deployment: upgrade withpg_upgrade, or a dump and a restore. - Hardening. The server's container drops every capability and runs
with
no-new-privileges; both containers' logs rotate (5 files of 10 MB); Compose gives the server 30 seconds to stop.
When the server cannot sign in to PostgreSQL
If the server's log says password authentication failed for user "mimicd",
PostgreSQL's log says why:
docker compose -f mimicd/compose.yaml logs postgres | grep -A1 'user "mimicd"'Never down -v a volume that may hold data. Repair the role in PostgreSQL
instead, as its superuser: give it the password in .env with
\password mimicd, or, if PostgreSQL says the role does not exist, make
it, give it the database (and the mimic schema and its tables, if the
volume holds them), then its password. The repository's mimicd/README.md
lists the statements. The server signs in at its next restart once the
role matches.