Clients

From a container

Valt0 works great with containers, in two distinct ways: a development mode and a deployment mode.

This page is about development, where your application runs in a container on your own machine and needs access to its secrets. For deployments, see Deployment.

Even inside a container, your application still connects to the Valt0 service running on your machine. To do that, the container needs to be able to read the Valt0 directory in your home folder, ~/.valt0, and the service’s socket file.

Valt0 has commands that set this up for you with minimal effort, depending on how you start the container.

Running a single container

If you start the container yourself with the Docker or Podman run command, valt0 container run adds what it needs.

It prints the volume mounts and environment variables the container needs, ready to drop into the command that starts it. So where you would run docker run some-image, run this instead:

docker run $(valt0 container run) some-image

Compose: using a fragment

With Compose you have two options. The first is a fragment Valt0 keeps in its own directory.

The fragment connects a container to the Valt0 service on your machine automatically. To use it, extend it from each service that needs secrets in your compose.yaml:

compose.yaml
services:
  your-service:
    build: .
    extends:
      file: ${HOME:-${USERPROFILE}}/.valt0/container/valt0.yaml
      service: valt0

Compose: using .env files

If your project uses .env files with Compose, valt0 container compose adds the mounts and environment variables the container needs to one of them.

Run without flags, it updates the .env file. To update a different one, such as development.env, name it with --env:

valt0 container compose --env development.env

Then use those variables in your compose.yaml, for the volumes and for the environment passed to the container:

compose.yaml
services:
  your-service:
    build: .
    volumes:
      - ${VALT0_APPDIR_MOUNT}
      - ${VALT0_SOCKET_PATH_MOUNT}
    environment:
      VALT0_APPDIR: ${VALT0_APPDIR}
      VALT0_SOCKET_PATH: ${VALT0_SOCKET_PATH}
      VALT0_TRANSPORT_CHANNEL: ${VALT0_TRANSPORT_CHANNEL}

If your Compose project does not use .env files, run the command with --stdout instead. It prints the variables to the terminal, and from there you can map them into compose.yaml by hand, as in the example above.