-
Notifications
You must be signed in to change notification settings - Fork 733
Description
Summary
The nerdctl run command is missing support for the --expose and --publish-all (-P) flags that are available in Docker CLI. These flags are essential for Docker compatibility and are commonly used in development tooling.
Docker Documentation
From Docker run reference:
--expose
Exposes a port without publishing it to the host system's interfaces. This makes the port available to linked containers.
docker run --expose 80 nginx:alpine-P / --publish-all
Publishes all exposed ports to random ports on the host. Docker binds each exposed port to a random port within an ephemeral port range.
docker run -P nginx:alpineThese flags work together: --expose declares which ports should be published, while -P makes them accessible on the host through random port assignments.
Podman Compatibility
Podman fully supports both flags:
--expose: Expose a port or range of ports (e.g.,--expose=3300-3310)-P/--publish-all: Publish all exposed ports to random ports on the host interfaces
Reference: Podman run documentation
Use Cases
-
IDE/Editor Extensions: VS Code Docker extension and similar tools use
--exposewith-Pto dynamically expose application ports during development without requiring users to specify exact port mappings. -
Development Workflows: Developers running multiple instances of the same service need random port allocation to avoid conflicts.
-
Container Orchestration: Some orchestration tools rely on
-Pfor service discovery patterns.
Current Workaround
For VS Code Docker extension users, a workaround has been implemented in PR #327 that logs warnings when these unsupported flags are used with Finch/nerdctl.
Expected Behavior
# Expose port 80 and publish it to a random host port
nerdctl run --expose 80 -P nginx:alpine
# Verify the port mapping
nerdctl port <container_id>
# Output: 80/tcp -> 0.0.0.0:49153Additional Context
This feature gap was identified while implementing Finch support for the VS Code Docker extension. Full Docker CLI compatibility for these networking flags would improve the developer experience for users choosing Finch/nerdctl as their container runtime.