Skip to content

Commit 3997635

Browse files
committed
feat: Add Fedora, UBI, and Podman-in-Podman templates
- Add Fedora template with multiple version options (41, 42, 43, latest, rawhide) - Add UBI template with version 8/9/10 and variants (ubi, ubi-minimal, ubi-init) - Add Podman-in-Podman template for nested container operations Signed-off-by: Shion Tanaka <shtanaka@redhat.com>
1 parent 00794d0 commit 3997635

19 files changed

Lines changed: 1132 additions & 0 deletions

File tree

.github/workflows/test-pr.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
docker-outside-of-docker: ./**/docker-outside-of-docker/**
2222
docker-outside-of-docker-compose: ./**/docker-outside-of-docker-compose/**
2323
docker-in-docker: ./**/docker-in-docker/**
24+
fedora: ./**/fedora/**
25+
ubi: ./**/ubi/**
26+
podman-in-podman: ./**/podman-in-podman/**
2427
dotnet: ./**/dotnet/**
2528
dotnet-fsharp: ./**/dotnet-fsharp/**
2629
dotnet-mssql: ./**/dotnet-mssql/**
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Fedora base image for Dev Containers
2+
# [Choice] Fedora version: 43, 42, 41, latest, rawhide
3+
ARG VARIANT=43
4+
FROM registry.fedoraproject.org/fedora:${VARIANT}
5+
6+
# Install base packages needed for Dev Container features
7+
RUN dnf install -y \
8+
curl \
9+
wget \
10+
ca-certificates \
11+
findutils \
12+
which \
13+
tar \
14+
gzip \
15+
unzip \
16+
shadow-utils \
17+
procps-ng \
18+
sudo \
19+
glibc-langpack-en \
20+
&& dnf clean all
21+
22+
# Set locale to avoid warnings
23+
ENV LANG=en_US.UTF-8 \
24+
LC_ALL=en_US.UTF-8
25+
26+
# Note: The common-utils feature will create the vscode user and install additional tools
27+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/fedora
3+
{
4+
"name": "Fedora",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
"VARIANT": "${templateOption:imageVariant}"
9+
}
10+
},
11+
12+
// Features to add to the dev container. More info: https://containers.dev/features.
13+
// Note: Zsh is installed but Bash remains the default shell (matching official templates)
14+
"features": {
15+
"ghcr.io/devcontainers/features/common-utils:2": {
16+
"installZsh": true,
17+
"installOhMyZsh": true,
18+
"username": "vscode",
19+
"userUid": "1000",
20+
"userGid": "1000",
21+
"upgradePackages": true
22+
},
23+
"ghcr.io/devcontainers/features/git:1": {}
24+
},
25+
26+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
27+
// "forwardPorts": [],
28+
29+
// Use 'postCreateCommand' to run commands after the container is created.
30+
// "postCreateCommand": "cat /etc/fedora-release",
31+
32+
// Configure tool-specific properties.
33+
// "customizations": {},
34+
35+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
36+
// "remoteUser": "root"
37+
"remoteUser": "vscode"
38+
}
39+
40+

src/fedora/NOTES.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Using this template
2+
3+
This template creates a Fedora-based development container. Fedora provides cutting-edge packages and is the upstream source for Red Hat Enterprise Linux.
4+
5+
### Fedora Version Options
6+
7+
| Version | Description |
8+
|---------|-------------|
9+
| `43` | Fedora 43 (current stable, October 2025) |
10+
| `42` | Fedora 42 (previous stable) |
11+
| `41` | Fedora 41 (extended support) |
12+
| `latest` | Latest stable Fedora release |
13+
| `rawhide` | Development/unstable version |
14+
15+
### Using with Podman
16+
17+
This template works well with Podman as the container engine. To configure VS Code to use Podman:
18+
19+
```json
20+
{
21+
"dev.containers.dockerPath": "podman"
22+
}
23+
```
24+
25+
### Adding Development Tools
26+
27+
You can add language-specific tools using [Dev Container Features](https://containers.dev/features). For example, to add Python:
28+
29+
```json
30+
"features": {
31+
"ghcr.io/devcontainers/features/python:1": {}
32+
}
33+
```
34+
35+
Or install packages directly using `dnf`:
36+
37+
```json
38+
"postCreateCommand": "sudo dnf install -y nodejs golang rust"
39+
```
40+
41+
### Multi-Architecture Support
42+
43+
Fedora images are available for both `x86_64` and `aarch64` (ARM64/Apple Silicon).
44+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"id": "fedora",
3+
"version": "1.0.0",
4+
"name": "Fedora",
5+
"description": "Simple Fedora container with Git and common utilities installed.",
6+
"documentationURL": "https://github.com/devcontainers/templates/tree/main/src/fedora",
7+
"publisher": "Dev Container Spec Maintainers",
8+
"licenseURL": "https://github.com/devcontainers/templates/blob/main/LICENSE",
9+
"options": {
10+
"imageVariant": {
11+
"type": "string",
12+
"description": "Fedora version:",
13+
"proposals": [
14+
"43",
15+
"42",
16+
"41",
17+
"latest",
18+
"rawhide"
19+
],
20+
"default": "43"
21+
}
22+
},
23+
"platforms": ["Any"],
24+
"optionalPaths": [
25+
".github/*"
26+
]
27+
}
28+
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Podman-in-Podman for Dev Containers
2+
# Allows running containers inside a dev container using Podman
3+
4+
# [Choice] Podman version tag: latest or any version (e.g., v5.7.1, v5.7, v5, 5.7.1)
5+
# Version tags use 'v' prefix (e.g., v5.7.1, v5.7, v5)
6+
# The 'v' prefix is optional in input - if you specify '5.7.1', it will be used as 'v5.7.1'
7+
# For best results, specify the full tag with 'v' prefix (e.g., 'v5.7.1', 'v5.7', 'v5')
8+
ARG VARIANT=latest
9+
ARG PODMAN_TAG
10+
ARG INSTALL_BUILDAH="true"
11+
ARG INSTALL_SKOPEO="true"
12+
13+
# Official Podman images from quay.io
14+
# Tag format: quay.io/podman/stable:latest or quay.io/podman/stable:v5.7.1, v5.7, v5, etc.
15+
# PODMAN_TAG is calculated and passed from devcontainer.json:
16+
# - 'latest' -> 'latest'
17+
# - Other versions -> add 'v' prefix if not present (e.g., '5.7.1' -> 'v5.7.1', 'v5.7.1' -> 'v5.7.1')
18+
# Default to 'latest' if PODMAN_TAG is not provided
19+
FROM quay.io/podman/stable:${PODMAN_TAG:-latest}
20+
21+
# For official Podman images, Podman is already installed
22+
# Install additional tools and optional components
23+
RUN dnf install -y \
24+
shadow-utils \
25+
sudo \
26+
curl \
27+
wget \
28+
ca-certificates \
29+
findutils \
30+
which \
31+
tar \
32+
gzip \
33+
unzip \
34+
procps-ng \
35+
glibc-langpack-en \
36+
podman-docker \
37+
&& dnf clean all
38+
39+
# Install optional tools based on build arguments
40+
# Note: ARG must be redeclared after FROM to be available in this stage
41+
ARG INSTALL_BUILDAH
42+
ARG INSTALL_SKOPEO
43+
RUN if [ "${INSTALL_BUILDAH}" = "true" ]; then \
44+
dnf install -y buildah && dnf clean all; \
45+
fi \
46+
&& if [ "${INSTALL_SKOPEO}" = "true" ]; then \
47+
dnf install -y skopeo && dnf clean all; \
48+
fi
49+
50+
# Configure subuid/subgid for rootless containers (will be set up by common-utils feature)
51+
# Using UID/GID 1001 to avoid conflicts with existing users in official Podman image
52+
RUN echo "vscode:100000:65536" >> /etc/subuid \
53+
&& echo "vscode:100000:65536" >> /etc/subgid \
54+
&& echo "1001:100000:65536" >> /etc/subuid \
55+
&& echo "1001:100000:65536" >> /etc/subgid
56+
57+
# Configure Podman for nested container operation
58+
RUN mkdir -p /etc/containers \
59+
&& echo '[containers]' > /etc/containers/containers.conf \
60+
&& echo 'netns="host"' >> /etc/containers/containers.conf \
61+
&& echo 'userns="host"' >> /etc/containers/containers.conf \
62+
&& echo 'ipcns="host"' >> /etc/containers/containers.conf \
63+
&& echo 'utsns="host"' >> /etc/containers/containers.conf \
64+
&& echo 'cgroupns="host"' >> /etc/containers/containers.conf \
65+
&& echo 'log_driver = "k8s-file"' >> /etc/containers/containers.conf \
66+
&& echo '' >> /etc/containers/containers.conf \
67+
&& echo '[engine]' >> /etc/containers/containers.conf \
68+
&& echo 'cgroup_manager = "cgroupfs"' >> /etc/containers/containers.conf \
69+
&& echo 'events_logger = "file"' >> /etc/containers/containers.conf
70+
71+
# Configure storage
72+
RUN echo '[storage]' > /etc/containers/storage.conf \
73+
&& echo 'driver = "overlay"' >> /etc/containers/storage.conf \
74+
&& echo '' >> /etc/containers/storage.conf \
75+
&& echo '[storage.options.overlay]' >> /etc/containers/storage.conf \
76+
&& echo 'mount_program = "/usr/bin/fuse-overlayfs"' >> /etc/containers/storage.conf
77+
78+
# Set locale to avoid warnings
79+
ENV LANG=en_US.UTF-8 \
80+
LC_ALL=en_US.UTF-8
81+
82+
# Create /etc/machine-id if it doesn't exist (required by some tools)
83+
# This is a dummy machine-id for container environments (32 hex chars, no hyphens per systemd spec)
84+
RUN if [ ! -f /etc/machine-id ]; then \
85+
if [ -f /proc/sys/kernel/random/uuid ]; then \
86+
# Convert UUID format to 32-char hex string (remove hyphens) \
87+
cat /proc/sys/kernel/random/uuid | tr -d '-' > /etc/machine-id; \
88+
elif command -v dbus-uuidgen >/dev/null 2>&1; then \
89+
dbus-uuidgen | tr -d '-' > /etc/machine-id; \
90+
else \
91+
# Fallback: generate 32 hex characters \
92+
od -An -N16 -tx1 /dev/urandom | tr -d ' \n' > /etc/machine-id || \
93+
echo "00000000000000000000000000000000" > /etc/machine-id; \
94+
fi; \
95+
fi
96+
97+
# Note: The common-utils feature will create the vscode user
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/podman-in-podman
3+
{
4+
"name": "Podman in Podman",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
"VARIANT": "${templateOption:imageVariant}",
9+
"PODMAN_TAG": "${templateOption:imageVariant}",
10+
"INSTALL_BUILDAH": "${templateOption:installBuildah}",
11+
"INSTALL_SKOPEO": "${templateOption:installSkopeo}"
12+
}
13+
},
14+
15+
// Required for nested container operations
16+
"runArgs": [
17+
"--privileged",
18+
"--security-opt", "label=disable"
19+
],
20+
21+
// Persistent storage for container images
22+
"mounts": [
23+
{
24+
"source": "devcontainer-podman-var-lib-${devcontainerId}",
25+
"target": "/var/lib/containers",
26+
"type": "volume"
27+
}
28+
],
29+
30+
// Features to add to the dev container. More info: https://containers.dev/features.
31+
// Note: Using UID/GID 1001 to avoid conflicts with podman user in official image
32+
// Zsh is installed but Bash remains the default shell (matching official templates)
33+
"features": {
34+
"ghcr.io/devcontainers/features/common-utils:2": {
35+
"installZsh": true,
36+
"installOhMyZsh": true,
37+
"username": "vscode",
38+
"userUid": "1001",
39+
"userGid": "1001",
40+
"upgradePackages": true
41+
},
42+
"ghcr.io/devcontainers/features/git:1": {}
43+
},
44+
45+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
46+
// "forwardPorts": [],
47+
48+
// Verify Podman is working (run as root for nested container operations)
49+
"postCreateCommand": "sudo podman --version && sudo podman info --format '{{.Host.OCIRuntime.Name}}'",
50+
51+
// Configure tool-specific properties.
52+
"customizations": {
53+
"vscode": {
54+
"extensions": [
55+
"redhat.vscode-yaml"
56+
]
57+
}
58+
},
59+
60+
// Using root for nested container operations to avoid user namespace issues
61+
// This is common for Podman-in-Podman scenarios
62+
"remoteUser": "root"
63+
}
64+
65+

0 commit comments

Comments
 (0)