A container is a lightweight, standalone package that includes everything needed to run a piece of software: the code, runtime, system tools, libraries, and settings. Containers make it easy to run applications reliably across different computers and environments.
venv
or Poetry) only isolate Python packages for a single project, but still use your system’s operating system and Python installation.Summary: Two virtual environments will have different versions of Python or packages, but two containers will have different installed software, even different operating systems. This makes containers more powerful for deploying applications.
Many cloud platforms use containers to host applications. For example:
Docker is the most popular tool for creating and running containers. With Docker, you can:
Dockerfile
)For more, see the Docker documentation.
GitHub Codespaces give you a Docker container in the cloud, called a dev container, to work in. A dev container is a special container with all the tools and dependencies your project needs. This means you can start coding immediately, without installing anything on your own computer, and without affecting your local setup.
You can configure the setup for each repository’s dev container by adding a configuration file. This configuration file appears in the repository as .devcontainer/devcontainer.json
. This file specifies:
mcr.microsoft.com/devcontainers/python:3.11
which comes with Python 3.11 pre-installed)poetry
for Python dependency management)When you create a new codespace, GitHub uses this configuration file to set up the dev container automatically.
Containers are a powerful way to package and run applications, making development and deployment more reliable and consistent. They go beyond virtual environments by isolating the entire operating system environment, not just Python packages. Tools like Docker and platforms like GitHub Codespaces, Google Cloud Engine, and Replit make it easy to use containers in real projects.