# Containers and Docker Basics

> Learn what a container really is, how it differs from a VM, and how to run, inspect and manage containers with Docker. Free notes, key concepts, resources and...

Canonical: https://www.internhack.in/roadmaps/tracks/devops/container-fundamentals
Last updated: 2026-11-28

Learn what a container really is, how it differs from a VM, and how to run, inspect and manage containers with Docker.

Beginner · about 8 hours · difficulty 2/5

Learn first: [Processes, Signals and Resources](https://www.internhack.in/roadmaps/tracks/devops/processes-signals), [How the Internet Works: TCP/IP and the OSI Model](https://www.internhack.in/roadmaps/tracks/devops/internet-tcpip)

A **container** is a normal Linux process isolated with kernel features: **namespaces** (its own view of PIDs, network, mounts, users) and **cgroups** (limits on CPU and memory). It is not a tiny VM; it shares the host kernel, which is why it starts in milliseconds.

### Key concepts

- An **image** is a read-only, layered filesystem plus metadata (entrypoint, env, ports). A **container** is a running instance of an image with a thin writable layer on top.
- **OCI** standards mean images built with Docker run on containerd, CRI-O, Podman and Kubernetes.
- Docker architecture: the `docker` CLI talks to the daemon, which uses **containerd** and **runc** underneath.

### Everyday commands

`docker run -d -p 8080:80 --name web nginx`, `docker ps`, `docker logs -f`, `docker exec -it web sh`, `docker inspect`, `docker stop`/`rm`, `docker images`, `docker system prune`.

### Data and networking

- **Volumes** persist data beyond the container; **bind mounts** map host paths (great for development).
- **Bridge networks** give containers DNS by name; `host` networking skips isolation.
- Resource limits: `--memory`, `--cpus`.

### Pitfalls

Storing data in the container layer (lost on removal), running as root by default, and treating containers like pets you SSH into and patch.

**Good enough to move on:** you can explain containers vs VMs, run a multi-container setup on a user-defined network with a volume, and debug a container with logs, exec and inspect.

## Key concepts

- **Namespaces and cgroups**
- **Images vs containers**
- **OCI, containerd and runc**
- **run, exec, logs, inspect**
- **Volumes and bind mounts**
- **Container networking**
- **Resource limits**
- **Podman**: Daemonless, rootless-friendly alternative CLI

## Mini project

Run Postgres with a named volume and a small web app on the same user-defined network, connect them by container name, then delete and recreate the Postgres container and prove the data survived.

## Check yourself

Why can a container start in under a second when a VM takes much longer, and what does that imply about kernel sharing?

## Free resources

- [Docker: Get started](https://docs.docker.com/get-started/) (Docker)
- [Open Container Initiative](https://opencontainers.org/) (OCI)

Previous: [Apache HTTP Server](https://www.internhack.in/roadmaps/tracks/devops/apache) · Next: [Building Good Images](https://www.internhack.in/roadmaps/tracks/devops/dockerfiles-images)

## More in Containers in Depth

- [Containers and Docker Basics](https://www.internhack.in/roadmaps/tracks/devops/container-fundamentals)
- [Building Good Images](https://www.internhack.in/roadmaps/tracks/devops/dockerfiles-images)
- [Container Registries](https://www.internhack.in/roadmaps/tracks/devops/container-registries)
- [Docker Compose for Multi-Container Apps](https://www.internhack.in/roadmaps/tracks/devops/docker-compose)
- [Container Security Essentials](https://www.internhack.in/roadmaps/tracks/devops/container-security)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
