Your DevOps study space

Real explanations. Videos with tests. Fresh exams every time. Keep the streak alive and watch the XP stack up.

Debugging containers · Docker Docs · StackwisePlanDevOps Debugging containers · Docker Docs · StackwiseCodePython Debugging containers · Docker Docs · StackwiseBuildDocker Debugging containers · Docker Docs · StackwiseTestDevOps Debugging containers · Docker Docs · StackwiseReleaseGit Debugging containers · Docker Docs · StackwiseDeployKubernetes Debugging containers · Docker Docs · StackwiseOperateLinux Debugging containers · Docker Docs · StackwiseMonitorDevOps

Pick a topic

Eight tracks, each with docs, a cheat sheet, videos and tests.

How it works

One loop, repeated until it sticks.

Jump back in

Picked up from where you left off.

Free forever

Your DevOps journey starts with one click.

Sign in with Google or GitHub to open every chapter, video, test and challenge. Your progress is saved wherever you learn.

Debugging containers

Sooner or later a container exits the moment it starts, a page won't load, or the disk fills up. Debugging containers follows a short routine: find out what state it's in, read what it said, look at how it was configured, then get inside if you need to.

Step 1: what state is it in?

$ docker ps -a
CONTAINER ID   IMAGE           STATUS                     NAMES
3f2a9c1b7d4e   demee/app:1.1   Exited (1) 4 seconds ago   web

docker ps only lists running containers; -a shows stopped ones too. The number in Exited (1) is the exit code, your first clue.

createddocker createrunningUp 3 minutesexitedExited (1)startstop or crashdocker startrestart policy: crash, start, crash...docker ps -a shows the state and the exit code
The exit code in Exited (1) is your first clue. A container that keeps flipping between running and exited is crashing on start: read its logs.

Step 2: read the logs

$ docker logs web                  # works on stopped containers too
$ docker logs --tail 50 -t web     # last 50 lines, with timestamps
$ docker logs --since 10m -f web   # last 10 minutes, then follow

Docker only captures what the main process writes to stdout and stderr. If your app logs to a file inside the container, docker logs stays empty; configure the app to log to the console instead.

Container exits immediately

A container lives exactly as long as its main process. Common reasons it ends straight away:

  • The app crashed on startup: missing environment variable, bad config, can't reach the database. The logs say so.
  • The command finished: docker run ubuntu starts bash, which exits at once because no input is attached (no -it). That's normal, not a bug.
  • The process went to the background: a start script runs a daemon that forks and returns (e.g. service nginx start). The main process must stay in the foreground: nginx -g 'daemon off;'.

To poke around in an image that won't stay up, replace its command with a shell:

$ docker run --rm -it --entrypoint sh demee/app:1.1

What the exit code means

CodeMeaningTypical cause
0Finished successfullyA one-off job completed, or the command simply ended
1General application errorUncaught exception, failed config check: read the logs
125 / 126 / 127Docker couldn't start it / command not executable / command not foundWrong docker run flags, missing execute permission, typo or missing binary in CMD
137128 + 9: killed with SIGKILLOut of memory, docker kill, or docker stop timed out
139128 + 11: segmentation faultA crash in native code: a C library, a native module, a bug or incompatibility below your app
143128 + 15: stopped by SIGTERMA normal docker stop that the app handled

docker inspect: the full picture

docker inspect web prints everything Docker knows about a container as JSON. Use --format to pick out fields:

$ docker inspect --format '{{.State.Status}} exit={{.State.ExitCode}} oom={{.State.OOMKilled}}' web
exited exit=137 oom=true           # 137 + OOMKilled: it ran out of memory
$ docker inspect --format '{{json .Mounts}}' web          # what is mounted where
$ docker inspect --format '{{json .Config.Env}}' web      # env vars it got
$ docker inspect --format '{{json .State.Health}}' web    # healthcheck results

Getting inside, even without a shell

$ docker exec -it web sh           # or bash, if the image has it
$ docker exec web env              # run a single command, no shell needed
OCI runtime exec failed: ... exec: "sh": executable file not found in $PATH

That error means a minimal image (distroless, scratch) with no shell. You can still debug from outside:

$ docker top web                          # processes running in it
$ docker cp web:/etc/app/config.yaml .    # copy a file out (works on stopped containers too)
$ docker diff web                         # files changed since it started
$ docker run --rm -it --network container:web nicolaka/netshoot
#   a toolbox container sharing web's network: curl, dig, ss, tcpdump...

Resource usage: docker stats

$ docker stats                 # live CPU %, MEM USAGE / LIMIT, NET I/O, PIDS
$ docker stats --no-stream     # one snapshot
$ docker run -d -m 512m --cpus 1.5 demee/app:1.1   # set limits

Memory creeping toward the limit ends in an exit code 137 with OOMKilled true.

"Port not reachable"

Work through it in order:

  1. Is it published? docker port web. No output means you forgot -p.
  2. Right container port? -p 8080:3000 only works if the app really listens on 3000.
  3. Is the app listening on 127.0.0.1? This is the classic one. Inside a container, 127.0.0.1 is the container's own loopback. Published traffic arrives on the container's network interface, so an app bound to 127.0.0.1 never sees it. Make it listen on 0.0.0.0: flask run --host=0.0.0.0, python manage.py runserver 0.0.0.0:8000, vite --host.
$ docker run --rm --network container:web nicolaka/netshoot ss -tln
LISTEN 0  128  127.0.0.1:5000  0.0.0.0:*    # bad: loopback only
LISTEN 0  128    0.0.0.0:5000  0.0.0.0:*    # good: all interfaces

Permission denied on a bind mount

A bind mount keeps the host's file owners as plain numbers (UID/GID). If the container runs as user node (UID 1000) and the host folder belongs to UID 1001 or to root, writes fail with EACCES: permission denied.

$ docker exec web id                  # which UID the app runs as
$ ls -ln ./data                        # which UID owns the host folder
# fixes, pick one:
$ docker run --user "$(id -u):$(id -g)" -v "$(pwd)/data":/app/data ...   # run as you
$ sudo chown -R 1000:1000 ./data       # give the folder to the container's UID
# ...or use a named volume instead of a bind mount

On Fedora/RHEL with SELinux, you may also need to add :z to the mount (-v "$(pwd)/data":/app/data:z) so the container is allowed to access it.

Disk full: cleaning up

$ docker system df            # space used by images, containers, volumes, build cache
$ docker system df -v         # the same, item by item
$ docker system prune         # stopped containers, unused networks,
                              # dangling images, unused build cache
$ docker system prune -a      # also every image not used by a container
$ docker image prune -a       # just images
$ docker builder prune        # just build cache
Volumes are left alone by default because they hold data. docker system prune --volumes adds anonymous volumes; named volumes are only removed with docker volume prune -a or docker volume rm. Read the confirmation prompt before you type y.

Quick error lookup

ErrorFix
Bind for 0.0.0.0:8080 failed: port is already allocatedAnother container or program uses that host port: pick another or stop it
Conflict. The container name "/web" is already in usedocker rm web first, or run with --rm so it's removed on exit
pull access denied ... may require 'docker login'Typo in the image name, or a private image: docker login
manifest unknownThat tag doesn't exist: check the tag list on the registry
exec format errorWrong CPU architecture: rebuild with --platform
no space left on devicedocker system df, then prune

Questions

Pick an answer. Get it wrong and you can try again right away, no waiting. 10 questions per topic - pick a filter below, then use Recreate questions for a fresh set on that topic.

Fresh questions every time

Exam

A mixed test across the whole site, shuffled so you never know which topic comes next. When you submit, every mistake comes with the reason and a jump to the exact moment in the video that explains it.

30 questions 6 topics 20 minute limit Up to 70 XP
1–4 answer · ←→ move
History

Essay

0 / 200-250 words
Sample answer
History
0:00 / 0:00
Not started

on YouTube
Subscribe

Topic progress

Activity

Achievements

Settings

Your profile and your account.

Profile details

* Required. Saved in this browser until you sign in.

Letters, numbers, dots, dashes and underscores.
0 / 160

Account

Checking…

App

Install Stackwise on your phone or computer. It opens in its own window from your home screen, and the Docs and cheat sheets you've opened keep working without internet.

Only admins can see this

Dashboard

Sign-ups, activity, messages and reviews in one place.

Prove it

Certificates

Pass a topic's test and get a certificate with its own public page you can share or add to LinkedIn. Each test is 10 questions drawn at random and graded on the server; you need 8 right, you have 15 minutes, and you get one try per topic a day.

From first command to production

Linux for DevOps

A path through Linux the way DevOps engineers use it: ten stages, every command explained with its flags, examples, real output and mistakes, the combinations engineers chain together, and incidents worked through step by step. Practise everything in a safe lab folder.

Before the interview

Interview prep

Questions that come up in real DevOps interviews, with the kind of answer that lands. Say yours out loud first, then compare. Each one links to the chapter that goes deeper.

    Private to you

    My notes

    Everything you wrote down while watching and reading, in one place. Saved to your account, never shown to anyone.