Feedback

Chat Icon

End-to-End Kubernetes with Rancher, RKE2, K3s, Fleet, Longhorn, and NeuVector

The full journey from nothing to production

Setting Up the Foundation
11%

The Container Image

Let's create a Docker image for our todo application. We start by creating a Dockerfile. Use the following command to create the file:

cat << EOF > $HOME/todo/app/Dockerfile
# Use an official Python runtime as a parent image
FROM python:3.12-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Make port 5000 available to the world outside this container
EXPOSE 5000
# Define environment variable
CMD ["python", "app.py"]
EOF

Create a .dockerignore file to exclude unnecessary files from the Docker build context:

cat << EOF > $HOME/todo/app/.dockerignore
.git
.gitignore
__pycache__
venv
tests
Dockerfile
EOF

Install Docker:

# Download the Docker installation script
curl -s https://get.docker.com | sh

Build the image using the following command:

End-to-End Kubernetes with Rancher, RKE2, K3s, Fleet, Longhorn, and NeuVector

The full journey from nothing to production

Enroll now to unlock all content and receive all future updates for free.

Unlock now  $35.00$26.25

Hurry! This limited time offer ends in:

To redeem this offer, copy the coupon code below and apply it at checkout:

Learn More