Skip to content

Podman / Docker containers

Services that run in containers (PostgreSQL, for example) can be managed together with process services. Everything goes through the engine’s CLI (podman start, stop -t, kill, inspect, logs -f, compose -p … up -d); commands are always argument arrays, never go through a shell, and add no dependencies.

Add a container service: required fields on top, build and container parameters collapsed below

Configuration

A service’s kind is container or compose, and the engine defaults to podman; to use Docker set "containerEngine": "docker" at the top level. For the fields (container, project, composeFile, readyCmd, image, createArgs) and examples see configuration.md.

Build from a Containerfile

When a service sets build, devhub builds the image and creates the container; without it the “existing container or image” mode above applies.

"web": { "kind": "container", "container": "my-web", "repo": "my-app", "build": "./web", "port": 8080 }
  • Minimal: "build": "./web". devhub looks for Containerfile in the context, then Dockerfile; the path is relative to the selected worktree, so switching worktree builds that worktree’s content. For the full form and ports, environment and volumes see configuration.md.
  • When it builds: at start devhub hashes the context content plus file, args and target and compares it with the image label devhub.build-hash; if equal it skips, and it builds only when different or when the image doesn’t exist. Content means file contents (modification times are ignored), honoring <file>.dockerignore, .containerignore and .dockerignore (the build file itself is always included); .git is excluded. A context over 20000 files or 1 GB is an immediate error; add a .dockerignore (for example excluding node_modules).
  • Rebuild: “Rebuild” on the service row, or devhub rebuild <service> (devhub start/restart --rebuild), always rebuilds the image. When the service is running the UI asks whether to restart; only with --restart is the old container stopped and replaced by one from the new image, otherwise it only builds and swaps at the next start.
  • Logs: build output is written to the service’s log file, and the log panel shows it during the build and after a failed build; once the build succeeds and the container runs, it shows the container’s own log. On failure the service doesn’t start, and the error and log explain why; both restart and “Rebuild and restart” build first, and when it fails the old container keeps running.
  • Timeout and cancel: a single build is limited to 20 minutes. Pressing “Stop” during a build (devhub stop) terminates it, that start ends as “Build cancelled” and no container is created.
  • Removing and recreating containers: containers devhub creates carry the labels devhub.managed, devhub.service and devhub.hash (a hash of the image id and all run parameters). At start, only when a container is stopped but its hash differs from the current one (image rebuilt, ports/environment/volumes/createArgs changed, or a relative volume of another worktree) is it rm’d and recreated, without -f and without -v, so volumes are untouched. Only these labeled containers belonging to the same service are handled; a user container with the same name (no labels) is always refused with an explanation and never deleted.
  • Engine: follows containerEngine (podman by default; for Docker set "containerEngine": "docker"), and if the podman machine isn’t running it is started automatically first.

Behavior

  • State: all containers are fetched at once with ps -a (cached for 2 seconds). While a container is running but the port, health check or healthcheck (including readyCmd) hasn’t passed, it shows “Starting”; compose is summarized per member as n/m running (the button is “Start the rest” when partly running). The state column is marked with a container icon, and uptime comes from the container’s StartedAt.
  • Readiness: with a port it waits for the port; if the image has a healthcheck it waits for healthy; if healthcheck is set (exec runs inside the container, http/tcp connect from the host to the published port) it waits for that to pass; timeouts follow stackTimeoutSec. The old readyCmd field is an alias of healthcheck.exec; for its behavior and state semantics see configuration.md.
  • Stop: stop -t <stopTimeoutSec>, with a countdown shown while stopping, and “Force stop” uses kill. Restart = stop then start. Compose only does up -d and stop.
  • Stacks: a container can join a stack and start along the dependsOn graph (members without dependsOn start together); state derivation, “Restart all” and conflict protection are all supported (containers have no worktree distinction, so worktrees aren’t compared).
  • podman machine: the header’s Podman pill shows the machine state and lets you start or stop it; when starting a container while the machine isn’t running, devhub first runs podman machine start automatically and waits for the engine, and if that fails it aborts and shows the reason. Before stopping the machine it asks for confirmation in the page and lists the containers that will stop with it. On Linux, or with Docker, where there is no machine concept, these buttons are hidden.
  • Logs: podman logs -f --tail 200 (podman compose logs -f for compose) is piped into the docked log; the stream ends when the container stops, and reopening resumes it.
  • Import from an existing container: after choosing “Container” for a new service, press “Import from an existing container” to list podman ps -a; choosing one prefills the name, image and port.
  • CLI and activity log: devhub status/start/stop/restart/logs support container services (status gains a type column, and containers show no worktree or pid); container operations and machine start/stop (machine.start/machine.stop) are all written to the activity log.
  • Never deleted: devhub never deletes your containers or volumes and offers no compose down; the only exception is Build from a Containerfile, where it removes only stale containers devhub itself created (carrying devhub labels). “Delete” in the UI removes only the config entry, not images or containers.

Limitations

Build: advanced build fields such as secrets, ssh, cache_from and multi-platform are not supported (build it yourself when you need them, then use image); stopping a service doesn’t remove the container automatically (recreation only happens at the next start); a stack restart stops first and then starts, so when a build fails the old container is already stopped; the engine is chosen only from the containerEngine setting and never falls back to Docker when podman is missing; images devhub builds are not cleaned up automatically, so run podman image prune yourself.

The Docker engine doesn’t report container start time, so the uptime column is empty; compose one-off containers (initialization jobs that finish and exit) also count as members and make the project show “partly running”; createArgs is used only when creating a container that doesn’t exist, so to change it later handle it on the engine yourself. For podman machine on Windows (WSL backend) see windows.md.