tmux ↔ Docker: Propagating Environment Variables to Existing Panes?
22K reputation · 26 Sept 2021, 08:45 UTC
The goal in many containerized workflows is to create a repeatable development environment that is shared across all tmux panes. In a Docker container, each pane typically starts a shell that inherits the container’s environment at launch time. When the container is running, developers often need to adjust environment variables to point to different services or credentials.
tmux exposes the set-environment command, optionally with the -g flag, to define global variables. However, the documentation and observed behavior indicate that these variables are only applied to windows or panes that are created after the command is issued. Existing panes retain the environment state they were launched with and do not see subsequent changes.
Because there is no built‑in mechanism to push an updated environment variable to all running panes, developers resort to re‑sourcing the configuration or manually recreating panes. This limitation becomes a bottleneck in truly repeatable environments, especially when Docker containers expect consistent variables across active sessions.
Is there a tmux command or extension that can retroactively propagate environment variable updates to all existing panes? Can a hook or plugin be employed to automatically reload the shell environment in each pane when a variable changes? What are the implications of such a feature for Docker exec sessions and the isolation of container processes?