cp, update, rename, stats

Operating on Live Containers

docker run, logs, exec and inspect cover the basics. This second tier of commands is what actually separates someone who has "tried Docker" from someone who operates it daily - they let you adjust a live container instead of always tearing it down and starting over.

docker cp - move files in and out of a container (running or stopped):

$ docker cp reports:/var/reports/q2.csv ./backup/   # container → host
$ docker cp ./config.ini reports:/etc/app/          # host → container

docker update - change resource limits and restart policy without recreating:

$ docker update --memory 256m --memory-swap 256m --restart unless-stopped worker

docker rename - fix a bad name with zero downtime: docker rename old new.

docker stats - live per-container CPU/memory/net/IO (add --no-stream for scripts):

NAME       CPU %   MEM USAGE / LIMIT   MEM %   NET I/O       PIDS
api        2.3%    89MiB / 256MiB      34.8%   1.2MB/450kB   12
worker     98.7%   201MiB / 256MiB     78.5%   0B/0B         48   ← trouble
Note: Know what update cannot change: image, command, env vars, ports, mounts. Those are immutable per container - changing them means recreate. This boundary (update vs recreate) is a favorite interview question because it's daily operational reality.
Goal: The Fix It Live and Copy In, Copy Out labs drill exactly these - including proving the container was never recreated.