How to Keep Ubuntu Docker Containers Running

Опубликовано: 20 Март 2026
на канале: RealClearComputing
94
0

In this video, I will show you how to start an Ubuntu container and keep it running in the background. By default, operating system containers like Ubuntu or Debian stop immediately after they are created because they don't have active services running.

I will walk you through the correct ways to fix this using the -dt flag, interactive mode (-it), and Docker Compose.

What you will learn:
Why do Docker containers exit immediately?
How to use the -dt flag to keep containers alive in the background.
How to use docker exec to connect to a running container.
How to use interactive mode and the "Ctrl+P, Ctrl+Q" shortcut to detach - without stopping the container.
How to configure tty: true in Docker Compose.

Commands Used in This Video
Method 1: Background Mode (Recommended) docker run -dt ubuntu
Method 2: Interactive Mode docker run -it ubuntu (To exit without stopping: Ctrl+P then Ctrl+Q)
Method 3: Docker Compose Add tty: true to your service configuration.

Link to the Commands: https://www.configserverfirewall.com/...

Timestamps
00:00 - Introduction
00:16 - Why Ubuntu containers stop immediately
01:12 - Three ways to keep a Docker container running
02:10 - Using Docker Compose (tty: true)
02:23 - Using the -dt flag to keep Ubuntu running
02:40 - Connecting with docker exec
03:09 - Starting a container in Interactive mode
03:48 - How to detach: Ctrl+P then Ctrl+Q
04:40 - Summary and my preferred method
05:10 - Next video: Port mapping and docker run

#Docker #Ubuntu #DevOps #dockertutorial #linux