Step-by-step guide to setting up Docker, Kubernetes, and all the essential tools you need for container development.
This guide provides detailed installation instructions for Docker and Kubernetes tools across Linux, macOS, and Windows platforms. Follow the steps for your operating system to create a complete container development environment.
After installation, verify that Docker is working correctly with these commands:
# Check Docker version
docker --version
# View detailed system information
docker info
# Run a test container
docker run --rm hello-world
If Docker is installed correctly, the hello-world container will download (if not already present) and run, displaying a success message:
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
...
This verification process confirms that:
The Docker client can connect to the Docker daemon
The daemon can download images from Docker Hub
The daemon can create and run containers
The container output is correctly returned to your terminal
Configure Docker to run without sudo and start on boot:
# Add your user to the docker group
sudo usermod -aG docker $USER
# Apply the new group membership (or log out and back in)
newgrp docker
# Enable Docker to start on boot
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
# Verify you can run Docker without sudo
docker run --rm hello-world
Adding users to the docker group grants effectively root privileges since containers can mount the host filesystem. Only add trusted users to this group.
brew install kubectl
# Verify installation
kubectl version --client
Using curl:
# Download kubectl binary
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
# Make it executable
chmod +x ./kubectl
# Move to a directory in your PATH
sudo mv ./kubectl /usr/local/bin/kubectl
# Verify installation
kubectl version --client
If you've installed Docker Desktop for Mac and enabled Kubernetes, kubectl is already installed and configured.
choco install kubernetes-cli
# Verify installation
kubectl version --client
Using curl and PowerShell:
# Create a directory for kubectl
mkdir -Path 'C:\kubectl'
# Add this directory to your PATH environment variable
$env:Path += ";C:\kubectl"
[Environment]::SetEnvironmentVariable("Path", $env:Path, [EnvironmentVariableTarget]::User)
# Download kubectl
curl -LO "https://dl.k8s.io/release/v1.29.0/bin/windows/amd64/kubectl.exe"
# Move kubectl to the directory we created
Move-Item .\kubectl.exe C:\kubectl\kubectl.exe
# Verify installation
kubectl version --client
Using winget:
winget install -e --id Kubernetes.kubectl
If you've installed Docker Desktop for Windows and enabled Kubernetes, kubectl is already installed and configured.
# Download the latest Minikube binary
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
# Make it executable and move to a directory in your PATH
sudo install minikube-linux-amd64 /usr/local/bin/minikube
# Verify installation
minikube version
brew install minikube
# Verify installation
minikube version
Using curl:
# Download the latest Minikube binary
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
# Make it executable and move to a directory in your PATH
sudo install minikube-darwin-amd64 /usr/local/bin/minikube
# Verify installation
minikube version
Minikube needs a "driver" to create the Kubernetes cluster. On Windows, you have several options:
Docker driver (recommended with WSL2):
minikube config set driver docker
Hyper-V driver (requires Windows Pro/Enterprise/Education):
# Enable Hyper-V if not already enabled
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
# Configure Minikube to use Hyper-V
minikube config set driver hyperv
Now that Minikube is installed, let's create your first local Kubernetes cluster:
# Start Minikube with default settings
minikube start
# Check cluster status
minikube status
# View cluster information
kubectl cluster-info
# View nodes in the cluster
kubectl get nodes
If successful, you should see output similar to:
š minikube v1.31.2 on Linux 5.15.0-60-generic
⨠Using the docker driver based on existing profile
š Starting control plane node minikube in cluster minikube
š Pulling base image ...
š Restarting existing docker container for "minikube" ...
š³ Preparing Kubernetes v1.28.3 on Docker 24.0.7 ...
š Verifying Kubernetes components...
āŖ Using image gcr.io/k8s-minikube/storage-provisioner:v5
š Enabled addons: default-storageclass, storage-provisioner
š Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
Now that you've installed all the necessary components, let's verify that everything is working correctly by performing some basic tests. This will ensure your development environment is properly set up before you start building applications.
Let's first confirm that Docker is functioning properly by running a few simple commands:
# Run a simple container and verify output
docker run --rm alpine echo "Hello from Docker container!"
This command pulls the lightweight Alpine Linux image (if not already present) and runs a container that displays a hello message. The --rm flag ensures the container is automatically removed after execution.
# List running containers to verify Docker daemon is responsive
docker ps
You should see a list of running containers (which might be empty if you don't have any containers running).
# Create a simple Docker network to test network functionality
docker network create test-network
# Verify the network was created
docker network ls | grep test-network
# Remove the test network when done
docker network rm test-network
If these commands execute without errors, your Docker installation is working correctly.
If you see "Hello from Docker container!" as output from the first command, Docker is successfully pulling images and running containers. The network commands verify that Docker's networking capabilities are functioning properly.
Now, let's verify that your Kubernetes cluster is running and can deploy applications:
# Check that Minikube is running with proper status
minikube status
You should see output indicating that Minikube is running, with the host, kubelet, and apiserver all showing "Running" status.
# Deploy a simple test application to your cluster
kubectl create deployment hello-kubernetes --image=k8s.gcr.io/echoserver:1.4
# Expose the deployment as a NodePort service
kubectl expose deployment hello-kubernetes --type=NodePort --port=8080
# Wait a moment for the pod to be ready
kubectl wait --for=condition=ready pod -l app=hello-kubernetes --timeout=60s
Let's check what we've created:
# Verify the pod is running
kubectl get pods -l app=hello-kubernetes
# Examine the created service
kubectl get services hello-kubernetes
# Get detailed information about our deployment
kubectl describe deployment hello-kubernetes
Finally, let's access our application:
# Open the service in your default browser
minikube service hello-kubernetes
If everything is working correctly, your browser should open automatically and display the echoserver application. This confirms that your Kubernetes cluster can successfully:
Once you've verified everything is working, let's clean up the test resources:
# Delete the service we created
kubectl delete service hello-kubernetes
# Delete the deployment
kubectl delete deployment hello-kubernetes
# Verify resources were removed
kubectl get all | grep hello-kubernetes
The last command should return no results, indicating all resources have been successfully removed.
It's good practice to clean up test resources when they're no longer needed to avoid cluttering your cluster and consuming unnecessary resources.
Now that you have a working Docker and Kubernetes environment, you're ready to start building, deploying, and managing containerized applications! In the next sections, we'll explore how to create Docker images, work with containers, and deploy applications to Kubernetes.
What You've Accomplished
You now have a fully functional local development environment with:
Docker for container management
Minikube for local Kubernetes development
kubectl for interacting with Kubernetes clusters
Essential tools for containerized application development
Where To Go Next
Learn Docker basics and build your first container
Understand Kubernetes concepts and architecture
Deploy multi-container applications with Kubernetes