nanyang-system-developers

Containers and Deployments

What is a Container?

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.

Containers vs Virtual Environments

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.

Why Use Containers?

Containers in the Cloud

Many cloud platforms use containers to host applications. For example:

Docker

Docker is the most popular tool for creating and running containers. With Docker, you can:

For more, see the Docker documentation.

Dev Containers in GitHub Codespaces

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:

When you create a new codespace, GitHub uses this configuration file to set up the dev container automatically.

Summary

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.

Further Reading