Back
2/5

Installation & First Steps

+15 XP on completion

#Installation & First Steps

After this lesson you'll know:

  • how to install Docker
  • the most important docker commands
  • how to start, stop, and delete containers

#Linux

curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
# Log out and back in

#macOS / Windows

Download Docker Desktop: https://docs.docker.com/desktop/

On Windows: install WSL2 first.

#Your Workflow

# Download image (without starting)
docker pull alpine

# Start a container
docker run alpine echo "Hello Docker"

# Interactive shell
docker run -it alpine sh

# Run in the background
docker run -d --name my-nginx -p 8080:80 nginx

# View logs
docker logs my-nginx

# Stop & Remove
docker stop my-nginx
docker rm my-nginx

#Essential flags

FlagMeaning
-dDetached (background)
-itInteractive + TTY (shell)
--rmAuto-remove after stop
-p 8080:80Port mapping Host:Container
--nameName instead of auto ID

#โœ‹ Try it out

  • docker run -it --rm alpine sh โ€” start an Alpine shell, try apk add curl and curl google.com
  • docker run -d --name web -p 8080:80 nginx โ€” visit http://localhost:8080
  • docker stop web && docker rm web โ€” clean up

#๐Ÿ“Œ Summary

  • docker pull downloads images, docker run starts containers
  • -d for background, -it for interactive, -p for ports
  • Stop containers with docker stop, remove with docker rm
Docker Basics Check

Test your knowledge with a quick quiz!

6 questions ยท +25 XP

โ† โ†’ to navigate