Open plinto
Docs›Guides

Run your service as a Docker image

Guide·5 min read

packager = Docker packs a service as a Docker image instead of an archive. Inside, it's the same layout an archive has, under /opt/<name>: your program, its libraries and its runtime, such as its JDK. Underneath, it has a base image, a package of your version group, such as DebianSlim. The image runs on your hosts in Docker, and the same image runs anywhere Docker or Podman does.

1. Name the packager and its base

plinto.conf
name = Billing
version = 1.4
build = JavaBuild
packager = Docker
main = com.acme.billing.Main
build-dependencies: {
    Java = 25
    JavaBuild = 1.0
    Docker = 1.0
    DebianSlim = 13
}
configuration/Docker.config
# The base image: a build dependency's name.
base = DebianSlim
# The platforms images are made for: linux-x64 by default.
platforms = [linux-x64, linux-aarch64]
# Who it runs as: 10001 by default, or uid:gid, or root.
user = 10001

The group pins DebianSlim like the JDK, so a newer base comes through a merge, and a hold keeps a group on the one it has. Its release is billing:1.4-7, one image for each platform, in lowercase as Docker wants it.

2. What's in it

Where What
the base's layers as they are, untouched
/opt/Billing/jdk/ the runtime: a JDK, or Node, Python or Erlang; none for Go and Rust
/opt/Billing/ the rest of what an archive holds, and bin/entrypoint
/etc/passwd the base's, with a line for the user it runs as

That line names the user plinto, with /opt/Billing for a home, so ~, $HOME and Java's user.home are a folder it can write. It's in the container's own files, so what's written there goes with the container: keep what must last on a volume. A uid the base already has keeps the base's line, and its home.

The runtime is a layer of its own, which changes only when the runtime does, so a host that has it from the release before downloads only the app's. The same inputs give the same image, byte for byte.

bin/entrypoint runs your scripts/ hooks inside the container, as a host runs an archive's:

Script When If it fails
pre-start.sh before the program, on every start it doesn't start
post-start.sh once the program has started the program stops, and the start fails
pre-stop.sh when the container is asked to stop, before the program is a warning
post-stop.sh once the program has exited a warning

/opt/Billing is the user's the image runs as, so whatever an archive writes beside itself, it writes there too.

3. Where it runs

Docker is root on a host, so an image goes only to hosts in a group with System services on, where plinto puts the deploy account in Docker's group. A group can't turn them off while one of its hosts runs an image. The hosts need Docker:

$ sudo apt-get install docker.io

Their agent says so within a minute. Each host's turn of a deployment is an archive's, its fourth step Load the image: the image runs under the environment's systemd service, so Restart, the journal and boot order are the same. Its Deploy settings are an archive's, and:

Setting What it does
ports what the container publishes: 8080:8080, which a load balancer needs
volumes folders it mounts: /srv/billing:/data; one not there yet is made for the image's user
health-url as the container sees itself, such as http://localhost:8080/health: it's asked at the container's own address, so it needn't publish a port to be checked
stop-timeout how long the container has to stop: its pre-stop, its program and its post-stop (10 s unset)

A sidecar beside it joins its network and reaches it by its name, billing.

4. A base of your own

When a service needs more than an imported image, such as fonts, a certificate or curl for its hooks, its base is a project of its own with a Dockerfile, built by DockerfileBuild:

JavaServiceBase/plinto.conf
name = JavaServiceBase
version = 1.0
build = DockerfileBuild
build-dependencies: {
    DockerfileBuild = 1.0
    DebianSlim = 13
}
JavaServiceBase/Dockerfile
FROM DebianSlim
RUN apt-get update \
 && apt-get install -y --no-install-recommends fonts-dejavu-core curl \
 && rm -rf /var/lib/apt/lists/*
COPY certs/acme-ca.crt /usr/local/share/ca-certificates/
RUN update-ca-certificates

FROM names a build dependency released as an image, never a registry, and ADD takes your project's files, never a URL. apt reaches Debian's mirrors. A service names it as its base, base = JavaServiceBase. It's built for the platform of the machine that builds it, and builds again when its Dockerfile or its base changes: what apt gives changes, so its release is what everyone builds on.

5. Bases from a registry

$ plinto import image docker.io/library/debian:trixie-20261027-slim==13.20261027 \
    --name docker.io/library/debian=DebianSlim --point 13

imports Debian's slim image for each platform as DebianSlim 13.20261027, the version after ==, every layer checked against its digest, and points the group's 13 at it. A name without a registry is Docker Hub's.