Architecture Overview
The container provider system consists of three main components:- Provider Layer (
IContainerProvider) - Handles provider initialization, authentication, and metadata - Manager Layer (
IContainerManager) - Implements container lifecycle operations (create, destroy) - Network Configuration - Manages isolation policies and network modes
/src/GZCTF/Services/Container/Provider/IContainerProvider.cs:1-17
Docker Provider
The Docker provider uses Docker.DotNet to communicate with the Docker daemon via REST API.Configuration
Docker provider configuration is loaded fromappsettings.json:
Network Modes
The Docker provider creates and manages three network types:Open Network
Open Network
Bridge network that allows outbound internet access with IP masquerading enabled.Reference:
/src/GZCTF/Services/Container/Provider/DockerProvider.cs:123-136Isolated Network
Isolated Network
Bridge network with IP masquerading disabled to prevent outbound traffic.Reference:
Internal networks disable port mapping entirely. GZCTF uses IP masquerading control instead.
See moby/moby#36174
/src/GZCTF/Services/Container/Provider/DockerProvider.cs:139-159Custom Network
Custom Network
User-defined network that GZCTF will attach to if it exists. Useful for connecting challenges to external services.Reference:
/src/GZCTF/Services/Container/Provider/DockerProvider.cs:117-120Container Creation
The Docker manager handles the complete container lifecycle:Container Creation Flow
/src/GZCTF/Services/Container/Manager/DockerManager.cs:71-259
Registry Authentication
Docker provider supports multiple registry configurations:/src/GZCTF/Services/Container/Provider/DockerProvider.cs:84-94
Kubernetes Provider
The Kubernetes provider uses the official Kubernetes C# client to manage pods and services.Configuration
If
KubeConfig is not specified and GZCTF is running in-cluster, it will automatically use the ServiceAccount token.Network Policies
Kubernetes provider uses NetworkPolicy resources instead of Docker bridge networks:/src/GZCTF/Services/Container/Provider/KubernetesProvider.cs:115-180
Pod Creation
Kubernetes manager creates pods with companion services:Pod Specification
/src/GZCTF/Services/Container/Manager/KubernetesManager.cs:72-125
Service Creation
Each pod gets a corresponding service for networking:/src/GZCTF/Services/Container/Manager/KubernetesManager.cs:151-168
Registry Secrets
Kubernetes provider createsdockerconfigjson secrets for private registries:
/src/GZCTF/Services/Container/Provider/KubernetesProvider.cs:182-214
Port Mapping Types
GZCTF supports three port mapping strategies:Default
Docker: Host port mapping
K8s: NodePort servicePlayers connect directly to
K8s: NodePort servicePlayers connect directly to
publicEntry:randomPortPlatformProxy
Players connect via WebSocket proxy at
/api/proxy/{containerId}Supports TCP traffic capture and PCAP generation.Randomize
Similar to Default but randomizes exposed ports for each container.
Environment Variable Injection
Both providers inject these variables into every container:GZCTF_FLAG- The dynamic flag for this team/challenge combinationGZCTF_TEAM_ID- The team identifier for logging and tracking
/src/GZCTF/Services/Container/Manager/DockerManager.cs:274-287
Resource Limits
Container resources are controlled via the challenge configuration:Container Resource Configuration
HostConfig:
Memory: MB × 1024 × 1024 (bytes)CPUPercent: cpuCount × 10 (percentage)
ResourceRequirements:
cpu: cpuCount × 100 (millicores)memory: memoryLimit (Mi)ephemeral-storage: storageLimit (Mi)
/src/GZCTF/Models/Internal/ContainerConfig.cs:1-60
Self-Network Attachment
When GZCTF itself runs in Docker, it automatically attaches to challenge networks to enable platform proxy mode:/src/GZCTF/Services/Container/Provider/DockerProvider.cs:161-176
Choosing a Provider
Use Docker When
Use Docker When
- Running small to medium deployments (< 50 concurrent containers)
- Simple networking requirements
- Deploying on a single host
- Lower complexity infrastructure
Use Kubernetes When
Use Kubernetes When
- Running large-scale competitions (100+ concurrent containers)
- Need multi-node orchestration
- Require advanced scheduling and resource management
- Need integration with existing K8s infrastructure
Next Steps
Traffic Capture
Learn how to capture and analyze container network traffic
Dynamic Flags
Understand flag generation and injection mechanisms