Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk10 min

How to Manage Docker Containers from the Command Line Without a Web UI

Manage Docker containers entirely from a terminal with practical commands for the full lifecycle, diagnostics, resource monitoring, cleanup, and Compose projects.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can run the complete day-to-day Docker container workflow from a terminal: list containers, create a named instance, watch its output, inspect its state, execute a process inside it, monitor resources, stop it gracefully, start it again, and remove it when it is no longer needed. The core pattern is docker run to create and start, docker ps to discover, docker logs and docker inspect to understand, docker exec to operate inside, and docker stop/docker rm to finish. Docker must be installed and your account must be able to reach the Docker daemon; on some installations that means prefixing commands with sudo or using an equivalent permission setup.

What you are managing

A Docker container is a running or stopped instance created from an image. Docker gives every container an ID, and you can assign a readable name with --name. The ID and name are interchangeable in most container commands; a name is easier to type and makes scripts and incident notes readable.

As an Amazon Associate I earn from qualifying purchases.

This guide stays at the container-operations level. It does not require a graphical dashboard, and it does not cover building images or designing orchestration systems. The examples use the Docker CLI directly against one daemon. If your installation requires elevated permissions, add sudo to the commands or configure the documented group or policy used by your operating system.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

List containers and identify their state

Start every investigation by seeing what exists.

docker ps

docker ps lists containers that are currently running. To include containers that have exited, use:

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
docker ps -a

The all-containers view is essential after a failed start: a container can disappear from the default listing simply because its primary process exited. Use the displayed name or ID in subsequent commands. Names are unique on a daemon, so choose a descriptive one when creating a container.

Create and start a named container

docker run creates a container from an image and starts it in one operation. This example starts an NGINX container in the background and publishes its port:

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

Here, --name web assigns the handle used later, -d runs detached from the terminal, and -p 8080:80 maps port 8080 on the Docker host to port 80 in the container. The final argument, nginx, is the image reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If a container with the requested name already exists, Docker will not silently replace it. List existing containers with docker ps -a, then decide whether to start that container, remove it after checking its data, or select a different name. If the image’s application exits immediately, detached mode still returns control to your shell; check docker ps -a and then read its logs.

A container has a lifecycle independent of the terminal that launched it. Closing a terminal does not by itself remove a detached container. Its state remains visible until you stop, remove, or otherwise recreate it.

Read application output and configuration

Follow logs for live output

Use logs when you need the application’s standard output and standard error:

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
docker logs -f web

The -f option follows new output as it arrives, making it useful while starting a service or reproducing a failure. Stop following with your terminal’s interrupt key; that detaches your log viewer, not the container itself. If the container is not running, its previously captured output can still explain why it exited.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inspect Docker’s object data

docker inspect web

docker inspect returns detailed, machine-readable information about the container object: its identity, state, configured command, networking, mounts, and other metadata recorded by Docker. Use it when the symptom is about configuration or state rather than application text. For example, logs may show that a service failed, while inspection can reveal the command Docker attempted to run or whether the container is marked running or stopped.

Because inspection output is extensive, search or format it with tools already available in your shell when you need one field. Keep the unfiltered output for a complete record when diagnosing a deployment or handing an issue to another operator.

Run an additional command inside a running container

docker exec starts a new process in an existing, running container. It does not restart the container’s primary process.

docker exec -it web sh

-i keeps standard input open and -t allocates a terminal, so together they provide an interactive session. This command works only when the image contains an executable named sh and the container’s primary process is still running. Minimal images may omit a shell; in that case, execute a diagnostic binary that the image actually includes, or inspect and log the container from the host instead.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The command supplied to docker exec must be an executable. Docker does not interpret shell operators automatically. To run a pipeline, variable expansion, or a chain such as two commands joined by &&, explicitly invoke a shell:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
docker exec -it web sh -c 'command1 && command2'

Use exec for short-lived administration, checking files, or validating a process from the container’s own environment. Changes made inside a container can be lost when that container is replaced, so treat an interactive session as an operational aid rather than a substitute for a reproducible image or external data store.

See processes and live resource consumption

List processes with top

docker top web

docker top shows the processes Docker can see in the container. It is a point-in-time process listing: use it to confirm that the expected server or worker exists, identify a runaway child process, or compare the process tree with what the image is supposed to launch.

Stream usage with stats

docker stats web

docker stats streams live resource measurements for running containers. It is useful for spotting sustained CPU activity, memory pressure, or unusual network and block-I/O behavior while an incident is occurring. It reports operational measurements, not an application performance benchmark.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On Linux, the CLI memory figure subtracts cache usage. Consequently, it can differ from the raw total exposed through Docker’s API. Do not treat a discrepancy between a host-level monitor, the API, and the CLI as proof that one of them is broken; first check which accounting method each view uses.

Stop a container safely, then start it again

Use graceful shutdown first

docker stop web

docker stop asks the container’s main process to exit cleanly. Docker sends the configured stop signal, normally SIGTERM, and waits through the configured grace period. If the process has not exited when that period ends, Docker sends SIGKILL. Graceful stopping gives applications an opportunity to flush data, close connections, and remove temporary state; it is the normal shutdown operation.

After stopping, confirm the state with docker ps -a and read the final log lines if the exit was unexpected. A container that remains listed but is stopped can be started again without creating a second container.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Start the existing container

docker start web

docker start starts a stopped container using its existing configuration. It does not create a fresh container or apply new run-time options. If the process exits again immediately, inspect the state and logs before repeatedly restarting it; a restart loop can hide the original configuration or application error.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reserve forced termination for a fallback

Forced termination is appropriate only when graceful shutdown cannot complete and the consequences are understood. It can interrupt cleanup and leave an application without time to flush state, so do not use a forceful command as the routine replacement for docker stop. Investigate why the main process ignores or exceeds its grace period before making forced termination part of an operating procedure.

Remove containers and understand automatic cleanup

Remove a stopped container explicitly

docker rm web

docker rm removes a container that is stopped. It removes the container object, not the image from which it was created. Verify the name and examine mounts before removing it, particularly when the container held state that another process still needs. If Docker reports that the container is running, stop it first and then retry the removal.

Use --rm for disposable runs

docker run --rm --name one-shot nginx

With --rm, Docker automatically removes the container after its process exits. Docker also removes anonymous volumes associated with that container. This is convenient for temporary jobs, but it changes your recovery options: once the process exits, the container object is no longer available for inspection or restart, and anonymous-volume data is removed with it.

Before adding --rm, determine how the application stores data and whether the mounts are anonymous or intentionally persistent. Do not use automatic cleanup for a workload whose stopped state, logs, or anonymous-volume contents you may need to investigate later.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the command that matches the question

Question Command What it provides
Which containers are active? docker ps Running containers only.
What exists, including failures? docker ps -a Running and stopped containers.
What did the application print? docker logs -f NAME Captured output, optionally followed live.
What configuration and state did Docker record? docker inspect NAME Detailed container metadata and state.
Can I run a diagnostic process inside it? docker exec -it NAME sh An interactive process, if the shell exists and the container is running.
Which processes are present? docker top NAME A process listing for the container.
Is it consuming unusual resources now? docker stats NAME Streaming resource measurements for a running container.
Can the application shut down cleanly? docker stop NAME Graceful stop with a signal and grace period.
Can I resume the same stopped instance? docker start NAME Starts the existing stopped container.
Should this stopped object be discarded? docker rm NAME Removes the stopped container object.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Operate Compose-managed containers from the terminal

If the containers belong to a Compose project, use the Compose command family so that operations stay scoped to that project and its services. The syntax begins with docker compose rather than a single-container name:

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
docker compose ps
docker compose logs
docker compose exec SERVICE sh
docker compose stop
docker compose start
docker compose down

docker compose ps shows the project’s service containers. Use logs for service output and exec to run a process in a selected service; provide the service name, and add sh only when that executable exists in the service image. The project-scoped stop and start operations let you pause and resume its services without switching to individual container IDs. Use down when the project should be taken down as a unit, after checking the project’s data and networking expectations.

Do not mix an ad-hoc docker run replacement into a Compose-managed application unless you intentionally want a separate container. Compose records the service definition, while a manually created container has a different lifecycle and is not controlled by the project commands.

A repeatable terminal runbook

  1. Discover: run docker ps; if the expected service is missing, run docker ps -a to include stopped instances.
  2. Create only when needed: use a readable --name with docker run. If that name already exists, inspect or start the existing object instead of creating a duplicate.
  3. Observe: follow output with docker logs -f NAME and consult docker inspect NAME when configuration or state is unclear.
  4. Diagnose in place: use docker top NAME for processes, docker stats NAME for live usage, and docker exec for an additional executable inside a running container.
  5. Shut down cleanly: issue docker stop NAME, allowing the configured signal and grace period to work.
  6. Resume or retire: use docker start NAME to reuse the stopped instance, or docker rm NAME after checking data and mounts. Choose --rm at creation time only for workloads where automatic container and anonymous-volume removal is acceptable.

Troubleshooting common command-line problems

“No such container”

Check spelling and whether you are addressing the correct daemon. Run docker ps -a and use the exact generated name, chosen name, or container ID shown there. If you expected a Compose service, run the Compose command in the project directory and use its service name rather than guessing a generated container name.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The container is absent from docker ps

The default listing excludes stopped containers. Use docker ps -a, then inspect logs and state. An exited primary process explains why docker exec cannot attach: exec requires a running container.

docker exec cannot find sh

The image may not contain that shell. Read the image’s available tools or use host-side logs and inspection. If you need a compound command, invoke an installed shell explicitly with sh -c; Docker will not parse && or other shell syntax on its own.

Stopping takes too long

The main process may be stuck or not handling the configured stop signal, or it may need more time than the grace period. Check logs and process state, then treat forceful termination as an exceptional fallback because it can interrupt cleanup and data flushing.

Data seems to have vanished after cleanup

Review the container’s mounts before using docker rm or selecting docker run --rm. Automatic removal also deletes associated anonymous volumes. Persistent application data must be mounted and managed deliberately rather than left in disposable container storage.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bottom line

A web UI is optional: the Docker CLI exposes the entire practical container lifecycle. Name containers when you create them, discover them with ps, separate output diagnosis (logs) from configuration diagnosis (inspect), use exec only for additional processes in running containers, monitor with top and stats, stop gracefully, and remove objects only after checking their data. For Compose projects, keep the same discipline with the project-scoped docker compose commands.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.