The snippet library.
Small, practical examples. Search by task or narrow things down below.
Assign a network-scoped alias
Docker / Compose: An alias gives an endpoint an additional name on that network.
Docker / Compose✓ Tested
Attach an existing container to another network
Docker / Compose: network connect adds an attachment without recreating the container.
Docker / Compose✓ Tested
Create a network marked for internal connectivity
Docker / Compose: The internal option disables normal external routing for that network.
Docker / Compose✓ Tested
Inspect a user-defined network’s driver
Docker / Compose: The default driver for a local user-defined network is bridge.
Docker / Compose✓ Tested
Keep scratch data only for the container lifetime
Docker / Compose: Separate tmpfs mounts do not share data between container runs.
Docker / Compose✓ Tested
Label a volume with its purpose
Docker / Compose: Volume labels support explicit ownership and selection.
Docker / Compose✓ Tested
List only volumes matching a label
Docker / Compose: A label filter avoids relying on broad name patterns.
Docker / Compose✓ Tested
Remove one network attachment
Docker / Compose: network disconnect removes the specified attachment while retaining the container.
Docker / Compose✓ Tested
Resolve a peer’s name on a user-defined network
Docker / Compose: The embedded DNS service resolves names on user-defined bridges.
Docker / Compose✓ Tested
Verify a read-only volume rejects writes
Docker / Compose: A failed write confirms the mount’s read-only behavior.
Docker / Compose✓ Tested