Skip to main content

Volumes and networks


Chapter objectives

  • Create and manage volumes
  • Browse volume files
  • Configure networks
  • Understand container connectivity

1 - Volume management

List of volumes

┌─────────────────────────────────────────────────────────────────┐
│ 📁 Volumes [+ Add volume] │
├─────────────────────────────────────────────────────────────────┤
│ □ Name Driver Mount point Used │
│ ──────────────────────────────────────────────────────────────│
│ □ postgres_data local /var/lib/docker... ✅ │
│ □ portainer_data local /var/lib/docker... ✅ │
│ □ nginx_config local /var/lib/docker... ✅ │
│ □ unused_volume local /var/lib/docker... ❌ │
│ │
│ Total: 4 volumes | Unused: 1 volume │
│ │
└─────────────────────────────────────────────────────────────────┘

Create a volume

┌─────────────────────────────────────────────────────────────────┐
│ + Add Volume │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Name: [my-data ] │
│ │
│ Driver: [local ▼] │
│ │
│ Driver options: │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ [type ] = [nfs ] [+ Add] │ │
│ │ [o ] = [addr=192... ] │ │
│ │ [device ] = [:/share ] │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ Access control: │
│ ( ) Unrestricted │
│ (•) Restricted to teams/users │
│ │
│ [Create the volume] │
│ │
└─────────────────────────────────────────────────────────────────┘

Types of volumes

TypeUseConfiguration
localLocal storageDefault
nfsNetwork storagetype=nfs, o=addr=..., device=:/path
cifsWindows sharetype=cifs, o=username=...,password=...
tmpfsRAMtype=tmpfs

2 - Browse a volume

File browser

┌─────────────────────────────────────────────────────────────────┐
│ 📁 postgres_data [⬆️ Upload] [📥 Download] │
├─────────────────────────────────────────────────────────────────┤
│ 📂 / │
├─────────────────────────────────────────────────────────────────┤
│ 📁 base/ 4.0 KB 2024-01-15 │
│ 📁 global/ 12 KB 2024-01-15 │
│ 📁 pg_commit_ts/ 4.0 KB 2024-01-15 │
│ 📁 pg_dynshmem/ 4.0 KB 2024-01-15 │
│ 📁 pg_logical/ 4.0 KB 2024-01-15 │
│ 📁 pg_wal/ 16 MB 2024-01-15 │
│ 📄 postgresql.conf 28 KB 2024-01-15 │
│ 📄 pg_hba.conf 4.5 KB 2024-01-15 │
│ 📄 pg_ident.conf 1.6 KB 2024-01-15 │
│ │
└─────────────────────────────────────────────────────────────────┘

Actions on files

ActionDescription
UploadUpload a file
DownloadDownload a file
RenameRename
DeleteDelete
EditEdit the content (text files)

File editing

┌─────────────────────────────────────────────────────────────────┐
│ 📝 Edit: postgresql.conf [Save] [Cancel]│
├─────────────────────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ # PostgreSQL configuration file │ │
│ │ │ │
│ │ listen_addresses = '*' │ │
│ │ port = 5432 │ │
│ │ max_connections = 100 │ │
│ │ │ │
│ │ shared_buffers = 128MB │ │
│ │ dynamic_shared_memory_type = posix │ │
│ │ │ │
│ │ log_destination = 'stderr' │ │
│ │ logging_collector = on │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘

3 - Details of a volume

Inspection

┌─────────────────────────────────────────────────────────────────┐
│ 📁 postgres_data │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Information: │
│ ─────────────────────────────────────────────────────────────│
│ Name: postgres_data │
│ Driver: local │
│ Mount point: /var/lib/docker/volumes/postgres_data/_data │
│ Created: 2024-01-15 10:30:00 │
│ Scope: local │
│ │
│ Used by: │
│ ─────────────────────────────────────────────────────────────│
│ • postgres (container) │
│ │
│ Labels: │
│ ─────────────────────────────────────────────────────────────│
│ com.docker.compose.project: myapp │
│ com.docker.compose.volume: postgres_data │
│ │
└─────────────────────────────────────────────────────────────────┘

4 - Network management

List of networks

┌─────────────────────────────────────────────────────────────────┐
│ 🌐 Networks [+ Add network] │
├─────────────────────────────────────────────────────────────────┤
│ □ Name Driver Scope Subnet │
│ ──────────────────────────────────────────────────────────────│
│ □ bridge bridge local 172.17.0.0/16 │
│ □ host host local - │
│ □ none null local - │
│ □ app_frontend bridge local 172.18.0.0/16 │
│ □ app_backend bridge local 172.19.0.0/16 │
│ │
└─────────────────────────────────────────────────────────────────┘

Create a network

┌─────────────────────────────────────────────────────────────────┐
│ + Add Network │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Name: [my-network ] │
│ │
│ Driver: [bridge ▼] │
│ • bridge - Single host networking │
│ • overlay - Multi-host networking (Swarm) │
│ • macvlan - Direct physical network │
│ │
│ ☐ Enable manual container attachment │
│ │
│ IPv4 configuration: │
│ ─────────────────────────────────────────────────────────────│
│ Subnet: [172.20.0.0/16 ] │
│ Gateway: [172.20.0.1 ] │
│ IP range: [172.20.1.0/24 ] │
│ │
│ Advanced options: │
│ ─────────────────────────────────────────────────────────────│
│ ☐ Isolated network (internal) │
│ ☐ Enable IPv6 │
│ │
│ Labels: │
│ [environment ] = [production ] [+ Add] │
│ │
│ [Create the network] │
│ │
└─────────────────────────────────────────────────────────────────┘

Creation options

OptionDescription
DriverNetwork type (bridge, overlay, macvlan)
SubnetIP address range
GatewayDefault gateway
IP rangeAllocation range
InternalNo external access
IPv6IPv6 support

5 - Details of a network

Inspection

┌─────────────────────────────────────────────────────────────────┐
│ 🌐 app_frontend │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Information: │
│ ─────────────────────────────────────────────────────────────│
│ Name: app_frontend │
│ ID: abc123def456... │
│ Driver: bridge │
│ Scope: local │
│ Created: 2024-01-15 10:30:00 │
│ Internal: No │
│ Attachable: Yes │
│ │
│ IPAM: │
│ ─────────────────────────────────────────────────────────────│
│ Driver: default │
│ Subnet: 172.18.0.0/16 │
│ Gateway: 172.18.0.1 │
│ │
│ Connected containers: │
│ ─────────────────────────────────────────────────────────────│
│ • nginx 172.18.0.2 │
│ • api 172.18.0.3 │
│ • frontend 172.18.0.4 │
│ │
└─────────────────────────────────────────────────────────────────┘

Connected containers

The network view shows all connected containers with their IPs:

┌─────────────────────────────────────────────────────────────────┐
│ Connected containers │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Container IPv4 Address IPv6 Address MAC Address │
│ ──────────────────────────────────────────────────────────────│
│ nginx 172.18.0.2 - 02:42:ac:... │
│ api 172.18.0.3 - 02:42:ac:... │
│ frontend 172.18.0.4 - 02:42:ac:... │
│ │
│ [+ Connect container] [- Disconnect selected] │
│ │
└─────────────────────────────────────────────────────────────────┘

6 - Connect/Disconnect containers

Connect a container to a network

┌─────────────────────────────────────────────────────────────────┐
│ Connect container to network │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Container: [redis ▼] │
│ │
│ Network: app_frontend │
│ │
│ IPv4 Address: [ ] (optional) │
│ │
│ Aliases: │
│ [cache ] [+ Add alias] │
│ │
│ [Connect] │
│ │
└─────────────────────────────────────────────────────────────────┘

From the container page

You can also manage a container's networks from its details page:

┌─────────────────────────────────────────────────────────────────┐
│ 📦 nginx - Networks │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Connected networks: │
│ ─────────────────────────────────────────────────────────────│
│ • app_frontend 172.18.0.2 [Leave] │
│ • app_backend 172.19.0.5 [Leave] │
│ │
│ [+ Join network] │
│ │
└─────────────────────────────────────────────────────────────────┘

7 - Overlay networks (Swarm)

Create an overlay network

In Swarm mode, you can create overlay networks:

┌─────────────────────────────────────────────────────────────────┐
│ + Add Network (Swarm) │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Name: [app-overlay ] │
│ │
│ Driver: [overlay ▼] │
│ │
│ Options: │
│ ☐ Enable encryption (--opt encrypted) │
│ ☑ Allow attachment from containers │
│ │
└─────────────────────────────────────────────────────────────────┘

8 - Best practices

Volumes

# ✅ Nommer les volumes explicitement
postgres_data
redis_cache
app_uploads

# ✅ Utiliser des labels
environment=production
app=myapp

# ✅ Sauvegarder régulièrement via Browse > Download

# ❌ Éviter les volumes anonymes

Networks

# ✅ Isoler les services par réseau
frontend-net (nginx, frontend)
backend-net (api, db, redis)

# ✅ Utiliser des noms explicites
myapp-frontend
myapp-backend

# ✅ Configurer des subnets pour éviter les conflits
172.20.0.0/16
172.21.0.0/16

# ✅ Utiliser internal pour les réseaux sensibles

Summary

ResourceActions
VolumesCreate, Browse, Edit, Upload, Download, Remove
NetworksCreate, Connect, Disconnect, Remove
Network typeUse
bridgeContainers on the same host
overlayMulti-host (Swarm)
macvlanPhysical network integration
Key points
  • Browse lets you explore and modify volume files
  • Custom networks provide isolation and internal DNS
  • Use descriptive names for volumes and networks
  • Internal networks protect backend services

Practical exercises

  1. Create a volume and explore its content with Browse
  2. Upload a configuration file into a volume
  3. Create a custom bridge network
  4. Connect two containers to the same network and test the ping

← Image management | Stacks and templates →