builtin:container#

Runs a container.

web: {
    uses: "builtin:container"
    with: {
        image:  "nginx:alpine"
        expose: web: {port: 80}
    }
}
FieldTypeDefaultDescription
imagestring-The container image to run. Set exactly one of image and build.
build#Build-Builds the image from a local Dockerfile on every run, then runs it. Set exactly one of image and build.
pullbool-Fetches the image before the container starts. It cannot be set together with build.
cmd[...string]-Replaces the command of the image.
entrypoint[...string]-Replaces the entrypoint of the image, such as ["sh", "-c"]. Unset keeps the image’s own entrypoint.
userstring-Sets the user the container runs as, such as "1000:1000" or "app".
workdirstring-Sets the working directory inside the container.
cpusstring & =~"^[0-9]+(\\.[0-9]+)?$"-Limits the CPUs the container can use, such as "1.5".
memorystring & =~"^[0-9]+[bkmg]?$"-Limits the memory the container can use, such as "512m". The suffix is b, k, m, or g.
env[string]: string-Holds extra environment variables for the container.
ports[...string]-Publish a container port on the host, such as "8080:80". Steps reach each other by step name and do not need a published port.
volumes[...string]-Mount a host path, such as "/src:/dst:ro".
proxybooltrueMounts the kevin CA certificate in the container and sets SSL_CERT_FILE to it, so the container trusts certificates from the kevin proxy. Outbound traffic goes through the proxy either way.
egress[...string]-Lists external hosts that this container can reach when proxy.egress.deny is true, in addition to proxy.egress.allow.
start_timeoutstring"30s"The maximum time to wait for the container to start, as a duration such as "30s".
expose[string]: #Expose-Makes a container port reachable from the host, published on 127.0.0.1 unless relay is true. The key names the entry in the console. The step is ready once the container is running, not when its ports accept connections. To give the port a name on the environment domain, add a builtin:route step.

#Build#

FieldTypeDefaultDescription
contextstring-Required. The directory to build from. A relative path is relative to the project directory.
dockerfilestring"Dockerfile"The Dockerfile to build, relative to context.
args[string]: string-Sets build arguments, as with "--build-arg".
targetstring-The stage of a multi-stage Dockerfile to build.

#Expose#

FieldTypeDefaultDescription
portint-Required. The container port to publish.
protocol"tcp" | "udp""tcp"The transport protocol of the port.
host_portint-Sets the port on the host. Unset, the OS picks a free port. Ignored when relay is true.
relaybool-Reaches the port through the relay container instead of a published host port. Use it when host ports are limited. The address is in the "expose_<name>" and "forward_<name>" system values instead of a "host_<port>" output.

Outputs#

KeyValue
idContainer ID.
nameContainer name.
ipContainer address on the project network.
host_<port>Host address of a published container port, such as host_80, from ports or an expose entry without relay.

System values#

For each expose entry with relay: true:

KeyValue
expose_<name>Relay address, as socks5://<relay>/<step>:<port>.
forward_<name>A 127.0.0.1:<port> address that forwards to the port through the relay.

Behavior#

  • Steps reach each other by step name on the project network.
  • A container step does not give itself a name on the environment domain. Use a builtin:route step.
  • Supports export: id, name, ip, and host_<port>, for a setup.<step> need or a command. Export fails if the container is not running.
  • With build, every start of the step builds the image, tags it kevin-<project>-<step>:latest in lowercase, and runs that tag. The build output appears in the step’s log.
  • Teardown removes the container and keeps a built image.
  • Build traffic is not proxied, and proxy.egress.deny does not apply to it.
  • Removed on teardown.
commands: sh: {
    needs: ["web"]
    run: ["docker", "exec", "-it", "${needs.web.out.name}", "sh"]
}