Page cover

1.2.1 - Introduction to Docker

Last updated Jan 22, 2025

Youtube Video | ~24 min

https://www.youtube.com/watch?v=EYNwNlOrpr0&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=4&pp=iAQB

To work through this video you will need Docker ๐Ÿ‹ downloaded, a terminal window โ–ช๏ธ, and a code editor ๐Ÿ“ of choice (Pycharm for me). Please see the 'Introduction' section if you need more info.

โœ๏ธ In this video, we learn about what Docker is, get a pipeline overview, and learn about Docker container and Docker image. Then we work through an example of how to build an image with Docker.

โš’๏ธ There is a supplemental video for those working on WSL found here: https://www.youtube.com/watch?v=Mv4zFm2AwzQ&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=17

What is...

"Docker helps developers build, share, run, and verify applications anywhere โ€” without tedious environment configuration or management." - https://www.docker.com/

https://blog.devgenius.io/docker-working-and-image-building-2d4901524617

Building a Container Image

Example code you want to deploy

import sys
import pandas as pd

print(sys.argv)
day = sys.argv[1]

# some pandas things

print(f'Finished for day {day}')
1

Dockerfile

Supplemental Info on writing a Dockerfile

๐Ÿ“ Create a new 'Dockerfile' in your code editor. I recommend adding the Docker 'plug in' to your editor.

FROM python:3.12.8
RUN pip install pandas
WORKDIR /app
COPY pipeline.py pipeline.py

ENTRYPOINT ["python", "pipeline.py"]

๐Ÿ”– https://docs.docker.com/reference/dockerfile/ - Dockerfile Instruction options i.e. 'FROM', 'RUN', etc.

2

Docker build

โฌ› Terminal

docker build -t {image_name}:{tag_name} .
-t
{image_name}:{tag_name}
.

used to denote adding a tag

replace these values for your image_name and tag_name

a build command that uses the current directory (.) as a build context

3

Docker run

โฌ› Terminal

docker run -it {image_name}:{tag_name}

๐Ÿ‘€ Note we will continue to build on this topic. We still need to talk about running containers, stopping containers, and viewing the front end of our containers.

๐Ÿงน Cleaning - be sure to open Docker Desktop and delete testing examples of your containers and images to free up space

Resources

My repo for this video can be found here

Not found

๐Ÿ”– https://docs.docker.com/get-started/docker-overview/

๐Ÿ”– https://github.com/HangenYuu/docker-cheatsheet

๐Ÿ“š I recommend working through the Docker site Intro & workshop if you're still confused on what Docker is

Last updated