> For the complete documentation index, see [llms.txt](https://data-engineering-zoomcamp-2025-t.gitbook.io/tinker0425/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://data-engineering-zoomcamp-2025-t.gitbook.io/tinker0425/module-1/1.2-docker-and-docker-compose/1.2.1-introduction-to-docker.md).

# 1.2.1 - Introduction to Docker

Last updated Jan 22, 2025

Youtube Video | \~24 min

{% embed url="<https://www.youtube.com/watch?v=EYNwNlOrpr0&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=4&pp=iAQB>" %}
<https://www.youtube.com/watch?v=EYNwNlOrpr0&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=4&pp=iAQB>
{% endembed %}

{% hint style="info" %}
To work through this video you will need Docker :whale2: downloaded, a terminal window :black\_small\_square:, and a code editor :pencil: of choice (Pycharm for me). Please see the '[Introduction](/tinker0425/introduction/introduction-and-set-up.md)' section if you need more info.
{% endhint %}

:writing\_hand: 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.

:hammer\_pick: 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...

{% tabs %}
{% tab title="Docker?" %}
"Docker helps developers build, share, run, and verify applications anywhere — without tedious environment configuration or management." - <https://www.docker.com/>
{% endtab %}

{% tab title="Container?" %}
"Simply put, containers are isolated processes for each of your app's components. Each component - the frontend React app, the Python API engine, and the database - runs in its own isolated environment, completely isolated from everything else on your machine." - <https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-a-container/>
{% endtab %}

{% tab title="Image?" %}
"If you’re new to container images, think of them as a standardized package that contains everything needed to run an application, including its files, configuration, and dependencies. These packages can then be distributed and shared with others." - <https://docs.docker.com/get-started/introduction/build-and-push-first-image/>
{% endtab %}

{% tab title="Tag?" %}
"A tag is a custom, human-readable identifier that's typically used to identify different versions or variants of an image. If no tag is specified, `latest` is used by default." - <https://docs.docker.com/get-started/docker-concepts/building-images/build-tag-and-publish-an-image/>
{% endtab %}
{% endtabs %}

{% embed url="<https://miro.medium.com/v2/resize:fit:1100/format:webp/1*tjTUpEi8h53-DMkweX2TDQ.png>" %}
<https://blog.devgenius.io/docker-working-and-image-building-2d4901524617>
{% endembed %}

### Building a Container *Image*

Example code you want to deploy

{% tabs %}
{% tab title="Ex 1 py" %}

```python
import sys
import pandas as pd

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

# some pandas things

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

{% endtab %}

{% tab title="Ex 2 py" %}

```python
from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"
```

.<https://docs.docker.com/build/concepts/dockerfile/>
{% endtab %}
{% endtabs %}

{% stepper %}
{% step %}

### Dockerfile

{% embed url="<https://docs.docker.com/get-started/docker-concepts/building-images/writing-a-dockerfile/>" %}
Supplemental Info on writing a Dockerfile
{% endembed %}

:pencil: Create a new 'Dockerfile' in your code editor. I recommend adding the Docker 'plug in' to your editor.

{% tabs %}
{% tab title="Ex 1" %}

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

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

{% endtab %}

{% tab title="Ex 2" %}

```docker
# syntax=docker/dockerfile:1
FROM ubuntu:22.04

# install app dependencies
RUN apt-get update && apt-get install -y python3 python3-pip
RUN pip install flask==3.0.*

# install app
COPY hello.py /

# final configuration
ENV FLASK_APP=hello
EXPOSE 8000
CMD ["flask", "run", "--host", "0.0.0.0", "--port", "8000"]
```

.<https://docs.docker.com/build/concepts/dockerfile/>
{% endtab %}
{% endtabs %}

:bookmark: <https://docs.docker.com/reference/dockerfile/> - Dockerfile Instruction options i.e. 'FROM', 'RUN', etc.
{% endstep %}

{% step %}

### Docker build

:black\_large\_square:  Terminal

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

<table><thead><tr><th>-t</th><th width="226">{image_name}:{tag_name}</th><th>.</th></tr></thead><tbody><tr><td>used to denote adding a tag</td><td>replace these values for your image_name and tag_name</td><td>a build command that uses the current directory (<code>.</code>) as a build context</td></tr></tbody></table>

{% embed url="<https://docs.docker.com/get-started/docker-concepts/building-images/build-tag-and-publish-an-image/>" %}
{% endstep %}

{% step %}

### Docker run

:black\_large\_square: Terminal

```bash
docker run -it {image_name}:{tag_name}
```

{% endstep %}
{% endstepper %}

:eyes:  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.

:broom: 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

{% @github-files/github-code-block url="<https://github.com/Tinker0425/de-zoomcamp-my-work/tree/master/module-01/docker/video_1>" %}

:bookmark:  <https://docs.docker.com/get-started/docker-overview/>

:bookmark: <https://github.com/HangenYuu/docker-cheatsheet>

:books: I recommend working through the Docker site Intro & workshop if you're still confused on what Docker is

{% embed url="<https://docs.docker.com/get-started/introduction/>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://data-engineering-zoomcamp-2025-t.gitbook.io/tinker0425/module-1/1.2-docker-and-docker-compose/1.2.1-introduction-to-docker.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
