Host tools
Make a command-line tool from the host available in the container, together with the environment variables it needs, such as a token or a server address.
Set up
This guide uses a small script as the tool. Save it as ~/.local/bin/mytool on the host and make it executable with chmod +x ~/.local/bin/mytool:
#!/bin/bash
# An example tool that prints a variable from its environment.
echo "MYTOOL_VAR=${MYTOOL_VAR:-<not set>}"Then use the files in examples/guides/host-tools:
# yaml-language-server: $schema=https://isodev.dyszkiewicz.me/config.schema.json
# A command-line tool from the host, with the variable it needs.
image: isodev-host-tools:latest
build:
context: image
volumes:
# The tool from the host. It must run in the container.
- type: bind
source: ~/.local/bin/mytool
target: /usr/local/bin/mytool
read_only: true
lifecycle:
on_exec:
# Passed to every command that Isodev runs in the container, when set on the host.
forward_env_vars: [MYTOOL_VAR]FROM ubuntu:24.04
ARG DEBIAN_FRONTEND=noninteractive
# mise installs tools to ~/.local/share/mise and puts them on PATH through its
# shims. /usr/local/bin comes first, so files mounted there win.
ENV PATH=/root/.local/bin:/usr/local/sbin:/usr/local/bin:/root/.local/share/mise/shims:/usr/sbin:/usr/bin:/sbin:/bin
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl git \
&& rm -rf /var/lib/apt/lists/*
# mise, which installs the tools.
RUN curl -fsSL https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise shFor a real tool, replace mytool and MYTOOL_VAR with its name and variables. The tool must run in the container: a script whose interpreter the image has, or a Linux binary for the container’s architecture that doesn’t depend on libraries the image lacks, such as a static Go binary. Otherwise, install the tool in the Dockerfile instead.
Use it
isodev up --recreate
MYTOOL_VAR=hello isodev exec mytoolThe tool prints MYTOOL_VAR=hello: Isodev reads MYTOOL_VAR from its own environment every time it runs a command, so the value can change without recreating the container. Forwarded variables reach isodev exec commands and agents, but not isodev enter shells.
After replacing the tool on the host, run isodev up --recreate: the mount keeps pointing to the file that was there when the container was created.
Trade-offs
- Forwarded variables are visible to everything the command runs, including agents and the tools they start. Forward secrets only to containers and commands you trust.