Bookmark this to keep an eye on my K8s notes updates!
Docker defines a container image as:
“A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.”
Example Dockerfile for Python Script:
# Base image selection
FROM ubuntu:20.04
# Software and libraries installation
RUN apt-get update && \\
apt-get -y install python3 python3-pip
# Copying code to the image
COPY my-app.py /app/
# Defining the working directory
WORKDIR /app
# Starting process when the container runs
CMD ["python3","my-app.py"]
Command for building the image:
docker build -t my-python-image -f Dockerfile
Parameters:
t my-python-image
: Specifies a name tag for the image.f Dockerfile
: Specifies the location of the Dockerfile.Docker provides built-in commands for pushing and pulling images from the registry:
docker push my-registry.com/my-python-image
docker pull my-registry.com/my-python-image