How to Find the Uptime of a Specific Docker Container in Ubuntu

When you are managing microservices or deploying applications on an Ubuntu server using Docker, monitoring container health is a daily necessity. If an application suddenly becomes unavailable, one of the first things you need to check is whether the container crashed and silently restarted, or if it has been running steadily without interruption.

To determine this, you need to check the “uptime” of the specific Docker container. Unlike checking the entire Ubuntu server’s uptime, you must query the Docker daemon directly to see exactly how long a specific container has been running.

This guide explains how to find the uptime of your Docker containers using the command line.

Checking All Container Uptimes

The standard docker ps command is the easiest way to get a quick overview of every active container on your system, including their current uptimes.

  1. Open your Ubuntu terminal or SSH into your server.
  2. Type the following command:
    docker ps
  3. Press Enter. (You may need to prepend sudo depending on how your Docker permissions are configured).

The terminal will output a wide table. Look for the column labeled STATUS.

Under the STATUS column, you will see text like Up 3 days, Up 14 hours, or Up 45 seconds. This is the exact duration the container has been running since it was last started or restarted.

Checking a Specific Container (Advanced Formatting)

If you have dozens of containers running, the docker ps output can be overwhelming and difficult to read. If you only care about one specific container and want a clean, isolated output, you can use the --format flag.

  1. First, you need the name or ID of the container you want to check.
  2. Type the following command, replacing my_container_name with your actual container’s name:
    docker ps -f "name=my_container_name" --format "table {{.Names}}\t{{.Status}}"
  3. Press Enter.

This command filters (-f) the list to only show the container matching your specified name, and formats the output to strip away the image IDs, ports, and creation dates. You will be left with a clean, two-column table displaying only the container’s name and its current uptime.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.