Menu
Coddy logo textTech

Running A Command

Part of the Introduction to Docker section of Coddy's Terminal journey — lesson 7 of 40.

You can tell a container exactly what command to run by adding it after the image name:

docker run alpine echo "hello from a container"

Docker starts a container from the alpine image, runs echo "hello from a container" inside it, prints the output, then the container exits. The structure is:

docker run IMAGE COMMAND [ARGUMENTS]

This is the everyday pattern for using a container as a throwaway environment: start it, run one command, and let it stop.

challenge icon

Challenge

Beginner

Run a container from the alpine image that prints containers are fun using echo.

Cheat sheet

Run a specific command in a container by appending it after the image name:

docker run IMAGE COMMAND [ARGUMENTS]

Example: start an alpine container, run echo, then exit:

docker run alpine echo "hello from a container"

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Introduction to Docker