Lesson 11 / 26

Naming Containers

Give containers memorable names instead of referring to random IDs.

--name

Without --name, Docker assigns a random name like happy_curie. Naming it yourself makes later commands readable.

docker run -d --name web -p 8080:80 nginx
docker logs web
docker stop web

Names must be unique

You can't reuse a name while another container (even a stopped one) still holds it — remove the old one first with docker rm.