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
| Flag | Meaning |
|---|---|
-d | Detached (background) |
-it | Interactive + TTY (shell) |
--rm | Auto-remove after stop |
-p 8080:80 | Port mapping Host:Container |
--name | Name instead of auto ID |
#โ Try it out
docker run -it --rm alpine shโ start an Alpine shell, tryapk add curlandcurl google.comdocker run -d --name web -p 8080:80 nginxโ visit http://localhost:8080docker 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