> For the complete documentation index, see [llms.txt](https://www.mlcompendium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.mlcompendium.com/ai-engineering/full-stack-and-ops-1/docker.md).

# Docker

A data-science environment has to run the same way everywhere, and Docker is how it gets packaged. The page goes from what an image is made of, to installing Docker and running Jupyter in it, to Compose for several containers, then Source-to-Image and a full beginner course.

The same notes are in [DevOps Courses](/ai-engineering/full-stack-and-ops-1/docker.md), [Docker for data science](/ai-engineering/full-stack-and-ops.md#docker-for-data-science), and [Jupyter](/data/engineering-intro/data-science-tools.md#jupyter).

An image is a stack of layers, so that is the first thing to understand. [What are Docker layers](https://medium.com/@jessgreb01/digging-into-docker-layers-c22f948ed612) is Jessica's dig into those layers, written while trying to view the contents of each layer that made up an image. With that picture, the next step is getting Docker onto a machine: [Install on Ubuntu](https://linuxconfig.org/how-to-install-docker-on-ubuntu-18-04-bionic-beaver) covers installing Docker on Ubuntu 18.04 Bionic Beaver.

For data science the usual first container is a notebook. [Many Jupyter Docker images (Spark too)](https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html) is the Selecting an Image page of the Docker Stacks documentation. [How to run Jupyter Docker 1](https://medium.com/@rahulvaish/jupyter-docker-badd38fd6b51) is Rahul Vaish's "Jupyter + Docker!", on how Docker lets you run ready-to-go Jupyter notebooks, and [2](https://medium.com/fundbox-engineering/overview-d3759e83969c) is the Fundbox post on running a local Jupyter and JupyterLab environment with Docker. Images take disk space, and [Tell Docker to run on a mounted disk](https://stackoverflow.com/questions/32070113/how-do-i-change-the-default-docker-container-location) is the Stack Overflow question on moving the default location, /var/lib/docker, to a bigger mounted drive. Once a notebook runs, a model can run too: [Docker, Keras, k8s, Flask serving](https://medium.com/analytics-vidhya/deploy-your-first-deep-learning-model-on-kubernetes-with-python-keras-flask-and-docker-575dc07d9e76) is Gus Cavanaugh's basic example of building a Keras model, serving it as a REST API with Flask, and deploying it with Docker and Kubernetes.

A real environment is rarely one container. [Compose](https://docs.docker.com/compose/) is the Docker documentation's introduction to using Docker Compose to define and run multi-container applications. The same Fundbox post appears again here as [Docker on Ubuntu, tutorial](https://medium.com/fundbox-engineering/overview-d3759e83969c). Docker Compose is simply a tool that allows you to describe a collection of multiple containers that can interact via their own network in a very straightforward way. [Docker for data science](https://aoyilmaz.medium.com/docker-in-data-science-and-a-friendly-beginner-to-docker-186fafdfbdeb) brings those pieces back to the data-science environment this page started with. A post on using VS Code to debug containers used to sit here; that address no longer opens and is kept at the end of the page.

## S2i

Writing Dockerfiles by hand is not the only way to get an image. Source-to-Image, S2I, builds Docker images out of gits, straight from the repository.

## Docker course

After those separate pieces, one course ties them together from the start. [Docker in 2 hours](https://www.youtube.com/watch?v=fqMOX6JJhGo\&list=RDQMjGhJ6Dhkx4Q\&start_radio=1) is freeCodeCamp.org's Docker Tutorial for Beginners, a full DevOps course on how to run applications in containers.

## Deprecated links

{% hint style="warning" %}
These links and images no longer work. The original wording is kept here. A same-resource copy, when one was checked, is used above.
{% endhint %}

* Containerize your ds environment using docker compose. This address no longer opens: <https://towardsdatascience.com/containerize-your-whole-data-science-environment-or-anything-you-want-with-docker-compose-e962b8ce8ce5>
* Using VS Code to debug containers. This address no longer opens: <https://nirradi.medium.com/vsc-vs-pycharm-developing-inside-docker-containers-4892c83d30e4>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.mlcompendium.com/ai-engineering/full-stack-and-ops-1/docker.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
