Chase AdamsChase Adams
AboutContentPromptsPlayground

Create an ad hoc interactive Docker container

Essays and updates on product, engineering, and AI by Chase Adams.

1 minute read

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:

  • container run: Runs a command in a new container
  • --rm: Automatically removes the container when it exits (when I'm done, this is really nice so that Docker doesn't end up with a bunch of dangling Docker processes [you can experiment with removing this flag, running this command a few time and exiting and running docker ps -a to see what that means])
  • -interactive: Keep STDIN open even if not attached
  • -tty: Allocate a pseudo-TTY
First Cohort
No Coding Experience Required

Build Your Website with AI—No Code Required

Learn to create and deploy professional websites using ChatGPT and Claude. Go from complete beginner to confident website builder.

Start Building Today

Post Details

Published
Feb 19, 2020
Category
Engineering
Share
Ask ChatGPT
Ask Claude

Latest Posts

Joining Rocket Money as VP of AI Engineering

Joining Rocket Money as VP of AI Engineering

Leading AI engineering at Rocket Money to write the playbook for how engineering teams operate in the AI era

AboutAI Workflow SpecContentStacksNewsletterPromptsRSS

Ask me anything

Loading...

Hi! Ask me anything about Chase's work.

I can answer questions based on his blog posts and articles.

Experimental: This chat is a side project I work on in my free time. Responses may vary in quality and accuracy.