Introduction
Docker is a platform for developing, shipping, and running applications in containers. Containers package an application with all its dependencies, ensuring consistent behavior across different environments.
Installing Docker
# Ubuntu/Debian
sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
# Add user to docker group (avoid sudo)
sudo usermod -aG docker $USER
Basic Commands
# Check Docker version
docker --version
# Pull an image
docker pull nginx
# Run a container
docker run -d -p 80:80 --name mynginx nginx
# List running containers
docker ps
# Stop and remove
docker stop mynginx
docker rm mynginx
Your First Container
# Run a simple web server
docker run -d -p 3000:80 --name website httpd
# Check it works
curl http://localhost:3000
# View logs
docker logs website
Summary
Docker simplifies application deployment by packaging everything into portable containers. Start with basic commands like run, ps, stop, and rm to manage your containers.
YouTip