Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

2 November 2026 · One command a day

How do I follow a Docker container's logs on Linux?

The docker logs command prints whatever a container writes to its standard output and standard error. With the right flags it shows you the last part of the log and then keeps the stream open, so new lines appear as they happen. You reach for it when a container is misbehaving, restarting or not answering requests, and you need to see what it is saying.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

The command

sudo docker logs -f --tail 100 appname

sudo is needed unless your user is in the docker group. docker logs reads the log Docker has stored for that container. -f (short for --follow) keeps the output open and prints new lines as they arrive. --tail 100 starts with only the last 100 lines, not the whole history, which can run to millions of lines on a busy container. appname is the container name or ID. If you are not sure of the name, list the running containers first.

What you will see

> appname@1.4.2 start
> node server.js

Connected to database at 127.0.0.1:5432
Server listening on port 3000
GET /health 200 3ms
GET / 200 41ms
POST /api/login 401 12ms
Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrapper.afterConnect [as oncomplete] (node:net:1607:16)
GET /health 200 2ms

Each line is exactly what the application printed, in order. Docker does not add its own formatting, so the format depends on the app. Error messages and stack traces show up mixed in with normal output, because standard error and standard output are shown together. Here the app started fine but could not reach a cache on port 6379. The cursor then waits at the bottom, and new lines appear as requests come in. Press Ctrl+C to stop following.

When to use it

Watch out for

docker logs only shows what the process writes to standard output and standard error. If the application writes its logs to a file inside the container, such as /var/log/app.log, this command will show little or nothing, even while the app is busy. In that case either set the app to log to stdout, or read the file from inside the container with sudo docker exec appname tail -f /var/log/app.log. Bear in mind too that the logs are deleted along with the container when you run docker rm, so copy anything you need before you remove it.

Questions people ask

Does pressing Ctrl+C stop the container?

No. Ctrl+C only stops the docker logs command. The container keeps running.

How do I add timestamps or limit it to recent lines?

Add -t to put a timestamp on each line, and --since 1h to show only the last hour, for example sudo docker logs -t --since 1h appname.

Reading a container's raw output like this is something you can only do on a server you control. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related server notes: How do I read the last 100 lines of a PM2 app's logs? · How do I follow a log file on Linux and still scroll back? · How do I watch the nginx error log in real time? · All daily notes