You should read about ”Docker” first. For the installation, just follow the great documentation on the Docker website.
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 ./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 imageNameStart a Docker container, that was created previously with the run command.
docker start containerNameMount 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 \
imageNameThis 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"]Designed & Developed by Jasper Anders