Ad space (banner)
AD

Got the fundamentals? A structured Docker course is a fast way to level up.

Find Docker courses on Udemy

Affiliate link. Costs you nothing extra.

🐳Docker Lessons
Lesson 7 / 45

Starting a Container with docker run

When you want to actually run something, use docker run. It creates a container from an image and starts it — the most fundamental Docker command of all.

The syntax is docker run [options] image [command]. If the image isn't present locally, Docker tries to pull it automatically.

Running docker run nginx creates a container from the nginx image and runs its default command. Without options it runs in the foreground, so your terminal stays occupied.

A common stumble is running the same command repeatedly and quietly accumulating containers. Each docker run creates a new container — to restart an existing one, use docker start.

In real work, it is the everyday command for spinning up databases, web servers, and one-off tools.

Docker
Try it (type this into the pseudo terminal)
docker run nginx

🧑‍💻 You can type this command into the Docker pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)