Git, containers and DevOps

Command docker

Manage Docker containers

Linux · Bash examples · commands run on the selected server

When to use docker

Use docker to inspect workloads on the selected Docker daemon. Confirm the context before acting: a client command can target a remote daemon, and daemon access often grants broad control over the host.

Syntax

docker [PARAMETERS] COMMAND

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

ps
Show running containers; -a also includes stopped containers.
logs
View the container log.
images
List of local images.

Usage examples

View containers

docker ps

Running containers on the selected daemon are listed.

View the latest messages from your container

docker logs --tail 100 app

A bounded tail of one container's log is printed.

View storage usage

docker system df

Docker's storage usage is summarized without deleting images, containers or volumes.

Notes and limitations

  • The client must have access to the selected Docker daemon; the context may point to a remote server.
  • Access to the Docker socket usually gives very broad permissions. Do not run prune or delete volumes without checking the data.

Common questions and troubleshooting

Why is access to the Docker socket denied?

The account lacks the required access or is targeting a different daemon. Follow administrator policy; socket access is a powerful privilege, not a routine harmless group fix.

Why does a stopped container not appear in docker ps?

The default list shows running containers. Include all containers when investigating exited workloads and inspect their state and logs.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man docker.