Typorithm · easy

Running Containers

run-containersdevopsrunportsexec
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Running Containers

0%

Containers

docker run starts a container from an image: -d detaches it, -p maps host:container ports, and --name labels it. docker ps lists running containers, docker logs -f streams output, and docker exec -it opens an interactive shell inside.

A container is an isolated process created from an image. docker run starts one: -d detaches it to the background, -p 8080:80 maps a host port to the container's port, and --name gives it a stable label.

docker ps lists the containers currently running, showing their image, ports, and names. Add -a to also see stopped ones.

docker logs -f web streams a container's stdout/stderr as it runs, and docker exec -it web sh drops you into an interactive shell inside the live container to inspect it.

01

docker run starts a container from an image.

02

-d detaches; -p maps host:container ports; --name labels it.

03

ps lists, logs -f streams, exec -it shells in.

docker run -d -p 8080:80 --name web nginx
docker ps
docker logs -f web
docker exec -it web sh

Read the implementation

Connect each part of the code to the concept before you type.

1. Start a container

docker run creates and starts a container from the nginx image as an isolated process.

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

2. Detach

-d runs the container in the background and returns the prompt immediately.

-d

3. Port mapping

-p maps host port 8080 to container port 80 so traffic reaches the app inside.

-p 8080:80

4. List containers

docker ps lists the currently running containers with their ports and names.

docker ps

5. Shell in

docker exec -it opens an interactive shell inside the already-running container.

docker exec -it web sh

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Running Containers: Lesson & Practice · Typorithm | ApplyDjinn