Docker CLI Basics
What is Docker CLI?
Docker Command Line Interface (CLI) is a powerful tool that allows users to interact with Docker daemon and manage containers, images, networks, and volumes. It provides a text-based interface for executing Docker commands and performing various operations.
Installation and Setup
Before using Docker CLI, ensure Docker is installed on your Ubuntu 22.04 system:
## Update package index
sudo apt update
## Install Docker
sudo apt install docker.io
## Verify installation
docker --version
Basic Docker CLI Structure
Docker CLI commands follow a standard syntax:
docker <object> <command> <options>
Command Categories
Category |
Purpose |
Management Commands |
Manage Docker objects |
Image Commands |
Pull, build, and manage images |
Container Commands |
Create, run, and control containers |
Network Commands |
Configure Docker networks |
Volume Commands |
Manage persistent data storage |
Authentication and Permissions
graph TD
A[User] --> B{Docker CLI}
B --> |Requires Sudo| C[Root Permissions]
B --> |User Group| D[Docker Group Access]
To avoid using sudo for every command, add your user to the docker group:
## Add current user to docker group
sudo usermod -aG docker $USER
## Restart session
newgrp docker
Docker CLI Configuration
Configuration files are typically located in:
/etc/docker/daemon.json
(system-wide)
~/.docker/config.json
(user-specific)
Key Concepts
- Docker Daemon: Background service managing Docker objects
- Docker Client: CLI tool for interacting with daemon
- Docker Objects: Images, Containers, Networks, Volumes
By understanding these basics, users can effectively leverage Docker CLI for containerization tasks. LabEx recommends practicing these fundamental commands to build a strong foundation in Docker management.