PowerShell Lab Complete!

You've mastered Docker container management from the command line!

Take the Quiz → Try GUI Lab

Docker Basics

1. Check Docker Version
Verify Docker is installed and check the client/server version.
docker version
2. View System Information
Display Docker system-wide information (containers, images, storage).
docker info

Image Management

3. Pull a Container Image
Download the Windows Server Core image from the registry.
docker pull mcr.microsoft.com/windows/servercore:ltsc2022
4. List Container Images
View all container images stored locally on the host.
docker images
5. Build a Custom Image
Build a container image from a Dockerfile in the current directory.
docker build -t hexworth/webapp:v1 .

Container Operations

6. Run a Container
Start a new detached container with a name and port mapping.
docker run -d --name web01 -p 8080:80 mcr.microsoft.com/windows/servercore:ltsc2022
7. List Running Containers
Show all currently running containers with their status.
docker ps
8. Inspect a Container
View detailed configuration and state of a specific container.
docker inspect web-app
9. View Container Logs
Check the output/logs from a running container.
docker logs web-app
10. Stop a Container
Gracefully stop a running container.
docker stop web-app
11. Remove a Container
Remove a stopped container to free up resources.
docker rm web-app

Networking & Storage

12. Create a Docker Network
Create a custom bridge network for container isolation.
docker network create --driver nat app-network
13. Create a Docker Volume
Create a persistent volume for data that survives container restarts.
docker volume create sql-data
14. Docker Compose Up
Start a multi-container application using docker-compose.
docker-compose up -d
Common Docker Flags:
-d = Detached (background)
-it = Interactive terminal
-p = Port mapping (host:container)
--name = Assign a name
-v = Volume mount
--network = Attach to network
Tip: Use docker --help or docker <command> --help for command reference. Windows containers use --isolation=hyperv for Hyper-V isolation.
Windows vs Linux Containers:
Windows Server supports both Windows and Linux containers. Use docker info to check the current OS/Architecture mode.
Container Lifecycle: Created → Running → Paused → Stopped → Removed. Use docker ps -a to see containers in all states, not just running ones.
Dockerfile Best Practices:
- Use multi-stage builds to reduce image size
- Minimize layers by combining RUN commands
- Use .dockerignore to exclude unnecessary files
- Pin specific image tags instead of :latest
- Run containers as non-root when possible
Docker Compose:
Define multi-container applications in a docker-compose.yml file. Services, networks, and volumes are all configured declaratively. Use docker-compose down to stop and remove all resources.
Container Isolation Modes:
Process Isolation - Containers share the host kernel (default on Server).
Hyper-V Isolation - Each container gets its own lightweight VM kernel. Use --isolation=hyperv for stronger security boundaries. Hyper-V isolation is required when running different Windows versions.
Cleanup Commands:
docker system prune - Remove all unused containers, networks, and images
docker volume prune - Remove all unused volumes
docker image prune -a - Remove all images not used by a container