labs
This is a collection of tutorials for learning how to use Docker with various tools. Contributions welcome.
Top Related Projects
The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
Production-Grade Container Scheduling and Management
:warning: This repository is deprecated and will be archived (Docker CE itself is NOT deprecated) see the https://github.com/docker/docker-ce/blob/master/README.md :warning:
Define and run multi-container applications with Docker
CLI tool for spawning and running containers according to the OCI specification
An open and reliable container runtime
Quick Overview
Docker Labs is a collection of tutorials and hands-on labs for learning Docker and container technologies. It provides a comprehensive set of resources for beginners and advanced users to explore various aspects of containerization, including Docker basics, orchestration, security, and best practices.
Pros
- Comprehensive coverage of Docker-related topics
- Hands-on approach with practical examples and exercises
- Regularly updated content to reflect the latest Docker features
- Suitable for both beginners and experienced users
Cons
- Some labs may become outdated as Docker evolves rapidly
- Requires a significant time investment to complete all labs
- May lack depth in certain advanced topics
- Some labs might require specific hardware or cloud resources
Getting Started
To get started with Docker Labs:
-
Clone the repository:
git clone https://github.com/docker/labs.git
-
Navigate to the desired lab directory:
cd labs/beginner
-
Follow the instructions in the README.md file for each lab.
-
Ensure you have Docker installed on your system before starting the labs.
-
For some labs, you may need to set up additional tools or cloud accounts as specified in the lab instructions.
Competitor Comparisons
The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
Pros of Moby
- Core Docker engine component with extensive functionality
- Active development with frequent updates and contributions
- Comprehensive documentation and extensive codebase
Cons of Moby
- Steeper learning curve for beginners
- More complex setup and configuration
- Larger project scope, which may be overwhelming for simple use cases
Code Comparison
Moby (engine implementation):
func (daemon *Daemon) containerStart(container *container.Container, checkpoint string, checkpointDir string, resetRestartManager bool) (err error) {
container.Lock()
defer container.Unlock()
if container.Running {
return nil
}
// ... (additional implementation)
}
Labs (tutorial example):
FROM python:3.7-alpine
WORKDIR /code
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
RUN apk add --no-cache gcc musl-dev linux-headers
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
EXPOSE 5000
COPY . .
CMD ["flask", "run"]
Summary
Moby is the core Docker engine project, offering extensive functionality and active development. It's suitable for advanced users and those requiring deep Docker integration. Labs, on the other hand, is a collection of tutorials and examples, making it more accessible for beginners and those looking to learn Docker concepts. While Moby provides the underlying implementation, Labs offers practical, hands-on learning experiences.
Production-Grade Container Scheduling and Management
Pros of Kubernetes
- More comprehensive container orchestration platform
- Robust ecosystem with extensive tooling and integrations
- Better suited for large-scale, complex deployments
Cons of Kubernetes
- Steeper learning curve and more complex setup
- Potentially overkill for smaller projects or simpler use cases
- Requires more resources to run effectively
Code Comparison
Kubernetes manifest example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Docker Compose example (from Labs):
version: '3'
services:
web:
image: nginx:alpine
ports:
- "8000:80"
volumes:
- ./app:/usr/share/nginx/html
The Kubernetes manifest provides more detailed configuration for deploying and managing containers at scale, while the Docker Compose file from Labs offers a simpler approach for local development and small-scale deployments.
:warning: This repository is deprecated and will be archived (Docker CE itself is NOT deprecated) see the https://github.com/docker/docker-ce/blob/master/README.md :warning:
Pros of docker-ce
- Contains the core Docker Engine source code, offering deeper insights into Docker's internals
- Provides a more comprehensive codebase for advanced Docker users and contributors
- Allows for custom builds and modifications of Docker Engine
Cons of docker-ce
- More complex and challenging for beginners to navigate and understand
- Less focused on educational content and hands-on learning experiences
- Requires more technical expertise to utilize effectively
Code Comparison
docker-ce (Golang):
func (daemon *Daemon) containerStart(container *container.Container, checkpoint string, checkpointDir string, resetRestartManager bool) (err error) {
container.Lock()
defer container.Unlock()
if container.Running {
return nil
}
// ... (additional code)
}
labs (Bash script):
#!/bin/bash
docker run -d -p 80:80 --name webserver nginx
docker ps
docker stop webserver
docker rm webserver
Summary
docker-ce is the core Docker Engine repository, offering a comprehensive codebase for advanced users and contributors. It provides deeper insights into Docker's internals but requires more technical expertise to navigate.
labs, on the other hand, focuses on educational content and hands-on learning experiences. It's more beginner-friendly and offers practical examples and tutorials for Docker usage.
The code comparison illustrates the difference in complexity, with docker-ce containing intricate Golang code for Docker's core functionality, while labs provides simple Bash scripts for practical Docker commands.
Define and run multi-container applications with Docker
Pros of Compose
- Official Docker tool for defining and running multi-container applications
- Simplifies container orchestration with a single YAML file
- Actively maintained and regularly updated
Cons of Compose
- Limited to local development and small-scale deployments
- Less comprehensive learning resources compared to Labs
- Focused solely on multi-container management, not broader Docker concepts
Code Comparison
Labs (Dockerfile example):
FROM python:3.7-alpine
WORKDIR /code
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
RUN apk add --no-cache gcc musl-dev linux-headers
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
CMD ["flask", "run"]
Compose (docker-compose.yml example):
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
redis:
image: "redis:alpine"
Labs provides a wider range of Docker examples and tutorials, covering various aspects of containerization. It's an excellent resource for learning Docker concepts and best practices. Compose, on the other hand, focuses specifically on simplifying multi-container application deployment and management. While Labs offers a broader educational experience, Compose provides a practical tool for streamlining container orchestration in development and small-scale production environments.
CLI tool for spawning and running containers according to the OCI specification
Pros of runc
- Focused on container runtime implementation, providing low-level functionality
- Part of the Open Container Initiative (OCI), ensuring industry-wide standards
- Lightweight and can be used as a building block for higher-level container tools
Cons of runc
- More complex to use directly compared to Docker Labs' educational approach
- Requires deeper understanding of container internals
- Less suitable for beginners learning container concepts
Code Comparison
runc (low-level container creation):
spec, err := loadSpec(context)
if err != nil {
return err
}
status, err := startContainer(context, spec)
Docker Labs (high-level Docker usage):
docker run -d --name web nginx
docker ps
docker stop web
Summary
runc is a low-level container runtime implementation, while Docker Labs is a collection of tutorials and examples for learning Docker. runc provides the core functionality for running containers, adhering to OCI standards, but requires more expertise to use directly. Docker Labs offers a more accessible approach to container concepts, making it better suited for educational purposes and beginners. The code examples highlight the difference in abstraction levels between the two projects.
An open and reliable container runtime
Pros of containerd
- Production-ready container runtime used in large-scale deployments
- Actively maintained with frequent updates and improvements
- Provides low-level container operations for advanced use cases
Cons of containerd
- Steeper learning curve for beginners compared to Docker Labs
- Requires more manual configuration and setup
- Less focus on educational content and tutorials
Code Comparison
containerd:
import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
)
client, err := containerd.New("/run/containerd/containerd.sock")
container, err := client.NewContainer(ctx, "redis", spec)
task, err := container.NewTask(ctx, cio.NewCreator(cio.WithStdio))
Docker Labs:
version: '3'
services:
web:
image: nginx:alpine
ports:
- "80:80"
db:
image: postgres:12
environment:
- POSTGRES_PASSWORD=mysecretpassword
Summary
containerd is a more advanced, production-focused container runtime, while Docker Labs is geared towards learning and experimentation. containerd offers greater control and scalability but requires more expertise. Docker Labs provides a simpler, more accessible environment for beginners to explore containerization concepts. The code examples illustrate the difference in complexity between the two, with containerd using Go for low-level operations and Docker Labs using YAML for declarative container definitions.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Docker Tutorials and Labs
At this time we are not actively adding labs to this repository. Our focus is on training.play-with-docker.com where new lab and workshop oriented content is being added. We welcome fixes to existing content. For any new content you wish to contribute, please use this repository:https://github.com/play-with-docker/play-with-docker.github.io.
This repo contains Docker labs and tutorials authored both by Docker, and by members of the community. We welcome contributions and want to grow the repo.
Docker tutorials:
- Docker for beginners
- Docker Swarm Mode
- Configuring developer tools and programming languages
- Docker for ASP.NET and Windows containers
- Building a 12 Factor app with Docker
- Docker Security
- Docker Networking
- Hands-on Labs from DockerCon US 2017
Community tutorials
- Docker Tutorials from the Community - links to a different repository
- Advanced Docker orchestration workshop - links to a different repository
Contributing
We want to see this repo grow, so if you have a tutorial to submit, or contributions to existing tutorials, please see this guide:
Top Related Projects
The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
Production-Grade Container Scheduling and Management
:warning: This repository is deprecated and will be archived (Docker CE itself is NOT deprecated) see the https://github.com/docker/docker-ce/blob/master/README.md :warning:
Define and run multi-container applications with Docker
CLI tool for spawning and running containers according to the OCI specification
An open and reliable container runtime
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot