Containers & OpenShift (Docker & oc)
Practical runbook for daily Docker container management, resource inspection, and OpenShift image registry operations.
Docker Resource Inspection
System Disk Usage
Inspect how much disk space is consumed by images, containers, local volumes, and build caches:
docker system dfFor verbose, per-item breakdown:
docker system df -vLive Resource Utilization
Stream real-time CPU, memory, network I/O, and block I/O statistics across running containers:
docker statsTo format or stream specific containers:
docker stats --no-streamContainer Process Table
Display the running processes inside a specific container directly from the host:
docker top <container_id_or_name>Host & Container File Transfer
Copy files or directories bidirectionally between a running container and the local filesystem:
# Copy from host to container
docker cp ./config.json <container_id>:/app/config.json
# Copy from container to host
docker cp <container_id>:/var/log/app.log ./app.logOpenShift CLI (oc) Registry Workflows
When working with private OpenShift container registries, configure the local Docker daemon and authenticate using short-lived tokens.
1. Cluster Authentication
Log into the target OpenShift cluster via CLI:
oc login --server=<cluster-api-url> --token=<auth-token>2. Insecure Registry Configuration
If the OpenShift internal image registry route uses self-signed or internal enterprise certificates, register the domain in Docker daemon’s configuration:
Edit /etc/docker/daemon.json (requires root privileges):
{
"insecure-registries": [
"default-route-openshift-image-registry.<cluster-domain>.com"
]
}Reload and restart Docker:
sudo systemctl daemon-reload
sudo systemctl restart docker3. Registry Authentication via CLI Token
Authenticate Docker directly against the OpenShift image registry using your active oc session token:
docker login -u openshift -p $(oc whoami -t) default-route-openshift-image-registry.<cluster-domain>.comReference Guides & Cheat Sheets
Tip
Offline Reference: A comprehensive Docker CLI Cheat Sheet (PDF) is available for offline download.