Skip to main content

Zenv

Zenv is container based virtual environments. The main goal of Zenv is to simplify access to applications inside container, making it seamless in use like native (host-machine) applications

Usage

> zenv init
Zenv created!

> # run `ls` command inside contaner
> ze ls

Motivation

As a developer, when set up a project locally, I usually need to install additional applications on the system. Of course, modern package managers such as poetry, pipenv, npm, cargo, ext, perfectly solve for us most of the problems with dependencies within a single stack of technologies. But they do not allow to solve the problem with the installation of system libraries. If you have a lot of projects that require different versions of system libraries, then you have problems

In production, this problem has long been solved by container insulation, and as a rule, it is a Docker. Therefore, many of my colleagues use docker-images and docker-compose, not only to run services in a production environment but also to develop and debug programs on a local machine

Unfortunately, there are several problems along the way:

  • Some of your familiar utilities may not be preinstalled in the container
  • If you try to install packages in the process, you will encounter the lack of necessary rights
  • Forget about debugging with print
  • The main thing is lost the usual experience, you can not use your favorite customized shell

Of course, the problems described above are solved by creating a docker image specifically for developing a specific project, zenv just helps to create such containers very simply

Features

  • Simplify: all interaction with the container occurs with one short command: ze

  • Zenv automatically forwarded current directory to the container with the same PWD

  • Zenv automatically forwarded current UserID, GroupID to container

    Therefore, files created in the container have the same rights as those created in the native console and you can also use sudo to get privileges

    > sudo ze <command>
    

    or

    > sudo !!
    
  • Zenv can forwarded environment vars as is native

    > MYVAR=LIVE!!!! ze env
    
  • And of course your could combinate native and containerized commands in Unix pipes

    > ze ls | head -7 | ze tail -5
    
  • Minimal performance impact

  • Customization: you can additionally control container parameters using Zenvfile

Install

  1. Make sure you have the latest version of Docker installed
  2. For linux, make sure you have your user’s rights are allowed to interact with doker
  3. Make sure that you have python version 3.6 or higher
  4. Execute:
    > sudo pip install zenv-cli
    # or
    > sudo pip3 install zenv-cli
    

How It works

By nature, zenv is a small automated layer over the official docker CLI

init

Command zenv init create Zenvfile in current directory. This file describes the relationship with the docker image and container that will be created to execute isolated commands.

By default, used image is ubuntu: latest. But you can change it by setting -i flag. For example:

> zenv init -i python:latest

Or edit Zenvfile manually

Execute

Command zenv exec <COMMAND> or it shot alias ze <COMMAND> run <COMMAND> in a container environment. When running the command:

  • Zenv checks current container status (running, stopped, removed), and up container if need.
  • The container run with the command sleep infinity. Therefore it will be easily accessible
  • UID and GID that ran the command are pushed into the container. Therefor your could use sudo ze <COMMAND>
  • When executing the command, the directory from the path where Zenvfile is located is forwarded to the container as is a current PWD. Therefor your could run ze from deep into directories relative to Zenvfile
  • Environment variables are also thrown into the container as a native.
    > MYVAR=SUPER ze env
    

To avoid conflicts between host and container variables, all installed system variables are placed in the blacklist when Zenvfile is created, from which editing can be removed

Configuration changes

Zenv records a fingerprint of the container creation settings in the Docker label zenv.config-hash. It covers the image, run options, startup command and init commands, including the aliases and execution settings used by initialization.

If these settings change, Zenv prints a warning to stderr and asks whether to recreate the container (default: no). Answering y removes the existing container, creates it with the updated configuration, runs initialization and retries the original command. Answering n or pressing Enter continues using the existing container. The same check applies to containers created before fingerprint tracking. Confirmation happens before starting the container or executing the command and preserves the command's stdout and exit code. With piped or noninteractive stdin, a mismatch stops execution without reading input.

Fingerprint checking is enabled by default and can be disabled:

[run]
check_zenvfile_changes = false

This disables comparison, warnings and confirmation, including for scripts and pipes. New containers still receive a fingerprint so checking can be re-enabled later. Changing this flag does not require recreating the container.

To apply updated creation settings, run zenv rm and retry. The next execution creates a container with the updated configuration. Files in the mounted project directory remain; changes made only inside the removed container are discarded.

Changing ordinary exec settings, host environment variables, UID/GID, TTY or the current subdirectory does not require recreating the container. Comments, TOML key order, alias descriptions and unused aliases do not affect the fingerprint. The fingerprint tracks configuration declarations, not changes inside image tags or files referenced by init commands.

Networks

Set a named network in the existing run options:

[run]
manage_network = true

[run.options]
network = "project-dev"

run.manage_network defaults to true. Set it to false to disable automatic network creation and deletion. The configured network is still passed to Docker and must already exist. This switch takes effect immediately and does not require recreating the container.

Before creating the container, Zenv attempts docker network create for each configured network, with the label zenv.managed-network=true. A list of names is also supported. Existing networks are reused; network command errors and output are ignored.

On zenv rm, Zenv attempts docker network rm for the networks explicitly listed in the current run.options.network, even if the container is already absent. It does not check labels or ownership: unused networks created manually or through Compose can also be removed. Docker decides whether removal is allowed; errors are ignored. No networks are managed when the setting is absent.

Set manage_network = false when automatic creation and deletion are unwanted, including when using system network modes or extended Docker network syntax.

Other commands

> zenv --help
Usage: zenv [OPTIONS] COMMAND [ARGS]...

  ZENV(Zen-env): Containers manager for developer environment

  Usage:

  > zenv init -i centos:latest & ze cat /etc/redhat-release

Options:
  --help  Show this message and exit.

Commands:
  exec      Call some command inside the container
  info      Show current container info
  init      Initialize Environment: create Zenvfile
  rm        Remove container (will stop the container, if need)
  stop      Stop container
  stop-all  Stop all zenv containers

Example install jupyter notebook

> mkgir notebooks
> cd notebooks
> zenv init -i python:3.7.3

After edit Zenvfile to explode notebook ports. Update ports = [] to ports = ["8888:8888"]

> sudo ze pip install jupyter numpy scipy matplotlib

Run notebook

> ze jupyter notebook --ip 0.0.0.0

launch your browser with url: http://localhost:8888

Also you could add this commands to Zenvfile:

[run]
init_commands = [
  [ "__create_user__"],
  ["pip", "install", "jupyter", "numpy", "scipy", "matplotlib"]
]

[commands]
notebook = ["jupyter", "notebook", "--ip", "0.0.0.0"]

And launch notebook with command

> ze notebook

Zenvfile

[main]
image = "ubuntu:latest"
name = "zenv-project"    # container name
debug = false            # for show docker commands

[run]
command = [ "__sleep__",]
init_commands = [ [ "__create_user__",],]

[exec]
env_file = ""
env_excludes = [ "TMPDIR",]

[run.options]
volume = [ "{zenvfilepath}:{zenvfilepath}:rw",]
detach = "true"
publish = []

[commands]
__sleep__ = [ "sleep", "365d",]
__create_user__ = [ "useradd", "-m", "-r", "-u", "{uid}", "-g", "{gid}", "zenv",]

Metadata

Release files for zenv-cli 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zenv-cli 0.5.1
File Size Uploaded Provenance Actions
zenv_cli-0.5.1.tar.gz 13.7 kB With provenance Details for zenv_cli-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zenv-cli 0.5.1
File Interpreter ABI Platform Actions
zenv_cli-0.5.1-py3-none-any.whl Python 3 none any Details for zenv_cli-0.5.1-py3-none-any.whl

Total release size: 27.0 kB

Release files / zenv_cli-0.5.1.tar.gz

Download URL zenv_cli-0.5.1.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
04210691a3c2eb00954cbb64378e9ece591d484421aff24397faf44809703d20
BLAKE2b-256 checksum
How to use checksums
885ec04316ac6b15f073f4a9cbab634b5d412aa23d85d17f4671f8a771fdfc48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / zenv_cli-0.5.1-py3-none-any.whl

Download URL zenv_cli-0.5.1-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e04aa710d8b10c8e7944d9cb37f7922c3e15e8c94753b64fc6a660eb25ee325
BLAKE2b-256 checksum
How to use checksums
8035baaa6bcf664a0003aa96544ec425b66a7b04bc6cf511698c935f1759492d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for zenv-cli 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zenv_cli-0.5.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page