FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

125 snippets foundClear filters
Docker / ComposeCompose service options

Add a fixed hostname mapping

Docker / Compose: extra_hosts adds an entry to the container’s hosts file.

Docker / Compose✓ Tested
Docker / ComposeNetworks & volume metadata

Assign a network-scoped alias

Docker / Compose: An alias gives an endpoint an additional name on that network.

Docker / Compose✓ Tested
Docker / ComposeGetting Started

Attach a descriptive label to a container

Docker / Compose: Attach a descriptive label to a container using a locally available Ubuntu image.

Docker / Compose✓ Tested
Docker / ComposeNetworks & volume metadata

Attach an existing container to another network

Docker / Compose: network connect adds an attachment without recreating the container.

Docker / Compose✓ Tested
Docker / ComposeStorage & isolation

Attach containers to a user-defined network

Create a dedicated network for a small group of containers.

network✓ Tested
Docker / ComposeGetting Started

Build an image with a default command

Docker / Compose: Build an image with a default command with a complete introductory Dockerfile.

Docker / Compose✓ Tested
Docker / ComposeImage management

Check that an image has layer history

Docker / Compose: history shows the instructions associated with image layers.

Docker / Compose✓ Tested
Docker / ComposeCompose service options

Choose a service’s internal hostname

Docker / Compose: hostname controls the name reported inside the container.

Docker / Compose✓ Tested
Docker / ComposeGetting Started

Choose an image’s default directory

Docker / Compose: Choose an image’s default directory with a complete introductory Dockerfile.

Docker / Compose✓ Tested
Docker / ComposeDockerfile patterns

Choose Bash with pipefail for build commands

Docker / Compose: SHELL changes the interpreter for subsequent shell-form instructions.

Docker / Compose✓ Tested
Docker / ComposeGetting Started

Choose the command a container executes

Docker / Compose: Choose the command a container executes using a locally available Ubuntu image.

Docker / Compose✓ Tested
Docker / ComposeLimits & process security

Choose the signal used for graceful stopping

Docker / Compose: The configured stop signal is recorded in container metadata.

Docker / Compose✓ Tested