Curious Chase

Curiously Chase

Create an ad hoc interactive Docker container

Share on Twitter

Often times I find myself wanting to spin up an ephemeral Docker container. This is the structure of the command I'll use:

docker container run --rm --interactive --tty <IMAGE> <COMMAND>

An example if I want to spin up an Alpine Linux container:

docker container run --rm --interactive --tty alpine sh

Running this command will open a new shell inside of my existing terminal window with the ability to interact with the container.

This command can be run more tersely with the shorthand flags for interactive and tty as well:

docker container run --rm -it alpine sh

The composition of the command:

Share on Twitter