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 11 / 45

Naming a Container with docker run --name

When you are tired of copying random container IDs, use --name. It gives the container a name you choose.

The syntax is docker run --name name image. Without it, Docker invents a whimsical name such as eager_turing.

Running docker run --name web nginx lets you refer to the container as web in every later command — docker stop web, docker logs web, and so on.

A common stumble is reusing a name that is already taken, which fails with a conflict error. Names must be unique, so remove the old container first.

In real work, meaningful names (web, db, redis) make operating a multi-container setup far easier.

Docker
Try it (type this into the pseudo terminal)
docker run --name web 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)