Table of Contents
- Quick Syntax Reference
- Command Syntax Styles
- Creating a Container
- Listing Containers
- Starting a Container
- Create & Start in One Step
- Ephemeral Containers
- Interactive Shells
- Exiting Containers
- Naming Containers
- Detached Mode
- Links and References
Quick Syntax Reference
Use this general pattern for Docker commands:Command Syntax Styles
Docker supports both legacy and grouped syntax. We’ll use the grouped style throughout this guide.Creating a Container
To create (but not start) a container:/var/lib/docker/:
containers/<container-ID>/.
Listing Containers
Usedocker container ls with options to filter the output:
Starting a Container
Start an existing container by its ID or name:Create & Start in One Step
Pull the image, create, and start the container:Ephemeral Containers
Some images (likeubuntu) don’t run a persistent process:
Interactive Shells
Keep STDIN open and allocate a pseudo-TTY with-it:
Always place options (
-i, -t, -d, --name) before the image name. Anything after the image name is interpreted as the container’s command.Exiting Containers
Runningexit inside an interactive shell stops the container:
Naming Containers
Assign a custom name at creation:Detached Mode
Run containers in the background with-d: