Contents

00 Getting Started

00 Motivation
02 Using Docker

02 🎱 Kubernetes

00 Understanding Kubernetes

Using Docker

You should read about ”Docker” first. For the installation, just follow the great documentation on the Docker website.

Useful Commands

Build a docker image

Build a docker image with the tag (-t) imageName. For this, you need a Dockefile (What is a Dockerfile?, Go to a Sample Dockerfile) in your ./ directory:

docker build -t imageName ./

Create and run a container

from an image named imageName. Name the container containerName and map its internal port 9000 to port 8000 of the host system.

docker run --name containerName -p 9000:8000 imageName

Start a Docker Container

Start a Docker container, that was created previously with the run command.

docker start containerName

Mount a File

Mount a file db.sqlite3 to a file with the same name under a specific path.

docker run --name containerName \
-p 8000:8000 \
--mount type=bind,source="$(pwd)"/db.sqlite3,target=/src/db.sqlite3 \
imageName

Sample Dockerfile

This is a sample Dockerfile for a generic Python application. As a base image, this sample uses python:3.9 provided by the docker hub.

# use a docker img from docker-hub as basis
# if no other location is provided docker will
# always pull from the dockerhub
FROM python:3.9

# Create a new directory in the container
RUN mkdir /src
# make /src the working directory of the container
WORKDIR /src

# Move pipfiles to project
ADD Pipfile Pipfile.lock ./

# Install pipenv
RUN pip install -U pip pipenv
# Use pipenv to intall dependencies
# you might want to change this if you don't use pipenv
RUN pipenv install

# Copy all files from your local -/ to /src/
# on the container
COPY . /src/

# expose the containers port 8000 to the host system
EXPOSE 8000

# echo "Hello World" on container start
CMD [ "echo", "Hello World"]
Imprint

Designed & Developed by Jasper Anders