Dev Containers
Ansible development works best when the editor, terminal, linters, and Python environment share one container image. This guide covers three related jobs:
- Using a Dev Container for day-to-day Ansible work
- Adding a
.devcontainer/config to a project (via ansible-creator) - Layering
ansible-dev-toolsonto an Execution Environment (EE) so that EE can be the Dev Container image
The Ansible extension follows ADR-003:
EE-based development uses Dev Containers, not docker exec / podman exec
routing.
Prerequisites
Section titled “Prerequisites”- Dev Containers
extension (
ms-vscode-remote.remote-containers) - Podman or Docker
ansible-creator(included withansible-dev-tools)
Using a Dev Container
Section titled “Using a Dev Container”- Open your project folder in VS Code or a compatible editor.
- Ensure the project has a
.devcontainer/directory (see Add a Dev Container file below). - Press
Ctrl+Shift+P/Cmd+Shift+P→ Dev Containers: Reopen in Container. - The editor reconnects inside the container. The Ansible extension activates against the container’s Python environment and collections.
Creator scaffolds Docker and Podman variants under .devcontainer/. Pick the
variant that matches your engine, or use the root devcontainer.json when
present.
Podman path for GUI-launched editors
Section titled “Podman path for GUI-launched editors”Apps started from the Dock/Start menu often miss shell PATH. Prefer an
absolute dev.containers.dockerPath:
{ "dev.containers.dockerPath": "/opt/podman/bin/podman"}On Linux the binary is often /usr/bin/podman. Confirm with command -v podman.
Add a Dev Container file
Section titled “Add a Dev Container file”Use ansible-creator as the source of truth for scaffolding (same templates as ansible-creator’s common devcontainer resources).
ansible-creator add resource devcontainer /path/to/project --image <image>--image accepts any container image reference (for example an EE tag, or
ghcr.io/ansible/community-ansible-dev-tools:latest). Defaults to auto when
omitted.
Creator tree / form
Section titled “Creator tree / form”In the Ansible sidebar, open Creator → Add → devcontainer, fill in path and image, then run.
ac_add_res_devc({ "path": "/path/to/project", "image": "ghcr.io/ansible/community-ansible-dev-tools:latest"})From an Execution Environment in the sidebar
Section titled “From an Execution Environment in the sidebar”Right-click an image under Execution Environments → Add Dev Container.
That opens the Creator form with --image set to the selected EE.
Generated layouts typically include Docker and Podman devcontainer.json
files with containers-in-containers (C-in-C) friendly runArgs (fuse device,
SYS_ADMIN, seccomp/apparmor settings). Those match the patterns used by
ansible-dev-tools.
Add ansible-dev-tools to an EE
Section titled “Add ansible-dev-tools to an EE”Most production EEs ship Ansible and collections but not the full developer
toolkit (ansible-lint, ansible-creator, molecule, and so on). Layer
ansible-dev-tools before using the EE as a Dev Container image.
Option A — Bake into execution-environment.yml
Section titled “Option A — Bake into execution-environment.yml”---version: 3
images: base_image: name: quay.io/ansible/ansible-runner:latest
dependencies: python_interpreter: package_system: python3.11 python: - ansible-dev-tools galaxy: collections: - name: ansible.netcommonansible-builder build -f execution-environment.yml -t my-ee-with-devtools:latestThen scaffold with --image my-ee-with-devtools:latest.
Option B — Outer Containerfile on an existing EE
Section titled “Option B — Outer Containerfile on an existing EE”When you cannot rebuild the EE definition, write an outer Containerfile that layers tools on top:
FROM registry.redhat.io/ansible-automation-platform/ee-supported-rhel9:latest
USER rootRUN pip3 install --no-cache-dir ansible-dev-toolsUSER 1000Build it:
podman build -t my-ee-with-devtools:latest -f Containerfile .docker build -t my-ee-with-devtools:latest -f Containerfile .Pass the tagged image to creator:
ansible-creator add resource devcontainer . --image my-ee-with-devtools:latestAlternatively keep the Containerfile under .devcontainer/ and point
devcontainer.json at it with "build": { "dockerfile": "Containerfile" }
instead of "image".
Inspect before you layer
Section titled “Inspect before you layer”Use the Execution Environments tree (or MCP list_execution_environments /
get_ee_details) to see whether ansible-dev-tools is already present.
Common images
Section titled “Common images”| Image | Role |
|---|---|
ghcr.io/ansible/community-ansible-dev-tools:latest |
Ready-made community ADT image |
registry.redhat.io/ansible-automation-platform/ee-supported-rhel9:latest |
Supported AAP EE (layer ADT if needed) |
registry.redhat.io/ansible-automation-platform/ee-minimal-rhel9:latest |
Minimal EE (layer ADT for interactive work) |
| Your custom EE | Prefer baking ADT into the EE definition |
Troubleshooting
Section titled “Troubleshooting”docker info / reopen failures with Podman
Section titled “docker info / reopen failures with Podman”Set absolute dev.containers.dockerPath as above, reload the window, retry
Reopen in Container.
SSH keys inside the container
Section titled “SSH keys inside the container”Prefer SSH agent forwarding on the host (ssh-add) — Dev Containers
forwards the agent. Avoid bind-mounting ~/.ssh.
Tools missing after reopen
Section titled “Tools missing after reopen”The image likely lacks ansible-dev-tools. Use Option A or B,
or install temporarily with pip install ansible-dev-tools inside the running
container.
Related
Section titled “Related”- Migrating from EE mode — map old
ansible.executionEnvironment.*settings - ansible-creator — scaffolding reference
- VS Code extension — sidebar views and Creator form
- Red Hat Dev Spaces — cloud workspaces with similar images