Container management
Chapter objectives
- Create containers through the interface
- Manage the container lifecycle
- Use logs and the console
- Monitor performance
1 - Create a container
Via the interface
- Go to Containers > + Add container
- Configure the parameters
Basic parameters
┌─────────────────────────────────────────────────────────────────┐
│ + Add container │
├──────────────────────────── ─────────────────────────────────────┤
│ │
│ Name: [mon-nginx ] │
│ │
│ Image: [nginx:alpine ] [🔍 Search] │
│ │
│ ☐ Always pull the image │
│ │
└─────────────────────────────────────────────────────────────────┘
Port configuration
┌─────────────────────────────────────────────────────────────────┐
│ Network ports configuration │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ☑ Publish all exposed ports │
│ │
│ Manual port mapping: │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Host Container Protocol │ │
│ │ [8080 ] [80 ] [TCP ▼] [+ Add port] │ │
│ │ [8443 ] [443 ] [TCP ▼] [🗑️] │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Advanced configuration
| Tab | Options |
|---|---|
| Command & logging | Command, entrypoint, working dir, user, console |
| Volumes | Bind mounts, volumes, tmpfs |
| Network | Network mode, hostname, DNS, hosts |
| Env | Environment variables |
| Labels | Docker labels |
| Restart policy | Restart policy |
| Runtime & Resources | CPU/memory limits, privileges |
| Capabilities | Linux capabilities |
Example: Create an nginx container
Paramètres:
- Name: web-server
- Image: nginx:alpine
- Ports: 8080:80
- Volume: ./html:/usr/share/nginx/html
- Restart policy: Unless stopped
2 - Actions on containers
Quick actions
| Icon | Action | Description |
|---|---|---|
| ▶️ | Start | Start the container |
| ⏹️ | Stop | Stop gracefully |
| 🔄 | Restart | Restart |
| ⏸️ | Pause | Pause |
| ▶️ | Unpause | Resume |
| 🔪 | Kill | Force stop (SIGKILL) |
| 🗑️ | Remove | Remove |
Advanced actions
| Action | Description |
|---|---|
| Duplicate/Edit | Create a copy or modify |
| Recreate | Recreate with the same config |
| Attach | Attach the terminal |
| Logs | View the logs |
| Inspect | Full JSON |
| Stats | Real-time metrics |
3 - Container logs
Log visualization
┌─────────────────────────────────────────────────────────────────┐
│ 📋 Logs - nginx │
├─────────────────────────────────────────────────────────────────┤
│ Options: [Auto-refresh ☑] [Timestamps ☑] [Lines: 100 ▼] │
│ [Wrap ☑] [Download] │
├─────────────────────────────────────────────────────────────────┤
│ 2024-01-15 10:30:05 /docker-entrypoint.sh: Launching nginx │
│ 2024-01-15 10:30:05 nginx: [notice] using the "epoll" event │
│ 2024-01-15 10:30:06 192.168.1.1 - - "GET / HTTP/1.1" 200 │
│ 2024-01-15 10:31:15 192.168.1.1 - - "GET /api HTTP/1.1" 404 │
│ 2024-01-15 10:32:00 192.168.1.2 - - "GET / HTTP/1.1" 200 │
│ │
└────────────────────────────────────────────────────────── ───────┘
Log options
| Option | Description |
|---|---|
| Auto-refresh | Automatic update |
| Timestamps | Display timestamps |
| Lines | Number of lines to display |
| Wrap | Automatic line wrapping |
| Download | Download the logs |
| Search | Search in the logs |
4 - Console (Exec)
Access the terminal
┌─────────────────────────────────────────────────────────────────┐
│ 💻 Console - nginx [Connect] │
├─────────────────────────────────────────────────────────────────┤
│ Command: [/bin/sh ▼] │
│ User: [root ] │
├─────────────────────────────────────────────────────────────────┤
│ │
│ / # ls -la │
│ total 80 │
│ drwxr-xr-x 1 root root 4096 Jan 15 10:30 . │
│ drwxr-xr-x 1 root root 4096 Jan 15 10:30 .. │
│ drwxr-xr-x 2 root root 4096 Jan 10 00:00 bin │
│ drwxr-xr-x 5 root root 340 Jan 15 10:30 dev │
│ drwxr-xr-x 1 root root 4096 Jan 15 10:30 etc │
│ / # _ │
│ │
└─────────────────────────────────────────────────────────────────┘
Useful commands in the console
# Vérifier les processus
ps aux
# Voir la configuration
cat /etc/nginx/nginx.conf
# Tester la connectivité
ping google.com
# Voir les variables d'environnement
env
# Vérifier l'espace disque
df -h
5 - Real-time statistics
Stats dashboard
┌─────────────────────────────────────────────────────────────────┐
│ 📊 Stats - nginx │
├─── ──────────────────────────────────────────────────────────────┤
│ │
│ CPU Usage │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ ████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2.5% │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ Memory Usage │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ ███ ███████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 35.2% │ │
│ │ 45.2 MB / 128 MB │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ Network I/O │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ ↓ 1.2 MB received ↑ 856 KB sent │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ Block I/O │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Read: 4.5 MB Write: 1.2 MB │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Available metrics
| Metric | Description |
|---|---|
| CPU % | CPU usage |
| Memory | RAM used / limit |
| Network RX | Data received |
| Network TX | Data sent |
| Block Read | Disk read |
| Block Write | Disk write |
| PIDs | Number of processes |
6 - Inspect a container
Detailed information
┌─────────────────────────────────────────────────────────────────┐
│ 🔍 Inspect - nginx │
├─────────────────────────────────────────────────────────────────┤
│ │
│ { │
│ "Id": "abc123def456...", │
│ "Created": "2024-01-15T10:30:00.000000000Z", │
│ "Path": "/docker-entrypoint.sh", │
│ "Args": ["nginx", "-g", "daemon off;"], │
│ "State": { │
│ "Status": "running", │
│ "Running": true, │
│ "StartedAt": "2024-01-15T10:30:05.000000000Z" │
│ }, │
│ "Image": "sha256:...", │
│ "NetworkSettings": { │
│ "IPAddress": "172.17.0.2", │
│ "Ports": { │
│ "80/tcp": [{"HostPort": "8080"}] │
│ } │
│ } │
│ } │
│ │
└─────────────────────────────────────────────────────────────────┘
7 - Duplicate/Edit
Modify a container
To modify an existing container:
- Select the container
- Click on Duplicate/Edit
- Modify the parameters
- Click on Deploy the container
┌─────────────────────────────────────────────────────────────────┐
│ Duplicate/Edit container: nginx │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ⚠️ This will stop and recreate the container │
│ │
│ Name: [nginx-v2 ] │
│ Image: [nginx:1.25-alpine ] (modified) │
│ │
│ Ports: │
│ [8080] → [80] │
│ [8443] → [443] (new) │
│ │
│ [Deploy the container] [Cancel] │
│ │
└─── ──────────────────────────────────────────────────────────────┘
8 - Bulk actions
Multiple selection
┌─────────────────────────────────────────────────────────────────┐
│ 📦 Containers │
├─────────────────────────────────────────────────────────────────┤
│ [Selected: 3] Actions: [Start] [Stop] [Kill] [Remove] │
├─────────────────────────────────────────────────────────────────┤
│ ☑ nginx 🟢 Running │
│ ☑ postgres 🟢 Running │
│ ☑ redis 🟢 Running │
│ □ old-app 🔴 Stopped │
│ │
└─────────────────────────────────────────────────────────────────┘
Filters
| Filter | Options |
|---|---|
| State | Running, Stopped, All |
| Name | Search by name |
| Image | Filter by image |
| Network | Filter by network |
9 - Best practices
Naming
# ✅ Bon
web-server
api-backend-prod
database-postgres-v15
# ❌ Mauvais
container1
test
abc
Resources
Always define limits:
Memory limit: 512 MB
CPU limit: 0.5
Restart policy
| Policy | Use |
|---|---|
| No | Tests |
| Always | Critical services |
| On-failure | Unstable applications |
| Unless-stopped | Standard production |
Summary
| Action | How |
|---|---|
| Create | + Add container |
| Start/Stop | Action buttons |
| Logs | Logs tab |
| Console | Console tab |
| Stats | Stats tab |
| Modify | Duplicate/Edit |
| Remove | Remove |
Key points
- The interface allows all CLI operations
- Logs and the console make debugging easier
- Stats enable real-time monitoring
- Duplicate/Edit lets you modify without downtime
Practical exercises
- Create an nginx container with ports 8080:80
- Access the console and list the files
- Monitor the statistics during a load
- Modify the container to change the image