Card 06/ 06
Recap: Running a Container
Five commands and one port rule, each with the card that covers it.
Running containers comes down to the five ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
docker run pulls, creates and starts, and only the pull touches the network | docker run: The Three Steps Behind One Command |
-p 8080:80 forwards port 8080 on your machine to port 80 in the container | Running nginx and Opening It in a Browser |
-p is host first, container second; the container's number is set by the program | Port Order in docker run -p |
docker ps shows what is running, -a shows what exited, and docker logs says why | Why a Container Exited: docker ps -a and docker logs |
docker exec -it gets you inside a running container; docker run would start another | Opening a Shell Inside a Running Container With docker exec |
When something goes wrong, the order is always the same: find the container with docker ps -a, read what it said with docker logs, and look inside with docker exec only if the logs are not enough.
← → move through sections and cards