Frequently Asked Questions About KodeKloud Docker Containerisation Blueprint

21 answers covering everything from basics to advanced usage.

// Basics

What exactly is Docker Engine and is it free?

Docker Engine is the free, open-source core of Docker — the docker CLI and the dockerd daemon that does the work. It runs on a 64-bit Linux server and is free for all use cases, including commercial. The paid subscription requirements apply only to Docker Desktop (the Mac/Windows GUI wrapper) when used commercially in companies above a certain size.

What is a Docker host?

A Docker host is the underlying machine, physical or virtual, where Docker Engine is installed and where containers run. Importantly, a container's internal IP address is only reachable from within the Docker host — external users can only reach a container through a published port mapping (-p). In large environments, containers run on virtual Docker hosts provisioned elastically.

Which image registries can I use besides Docker Hub?

Docker Hub is the most popular public registry, but you can also use GitHub Container Registry, Google Artifact Registry, AWS Elastic Container Registry (ECR), and Azure Container Registry. These are especially useful for private images, tighter cloud integration, and avoiding Docker Hub rate limits in CI. Always note and pin the exact supported tag for each image regardless of registry.

// How To

How do I install Docker Engine on Ubuntu?

Add Docker's apt repository, then run apt install to pull docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin, and docker-compose-plugin. Confirm the daemon is running with systemctl status docker, then validate the full stack by running docker run hello-world. If the hello-world image downloads and prints its message, your installation is complete and working.

What is the difference between -i, -t, and -it in Docker?

The -i flag maps standard input so you can pipe or type data into the container; -t attaches a pseudo-terminal for coloured, formatted output; -it combines both for interactive shell sessions. Use -i alone when piping data such as streaming a SQL file — adding -t will make Docker refuse the pipe because pipes are not terminals. Use -t alone for formatted output without keyboard input.

How do I pipe a SQL file into a containerised database?

Use docker run -i (not -it) to connect standard input without requiring a terminal, then pipe the SQL dump in. The -i flag streams the file directly into the container's stdin and on into the database. Adding -t would cause Docker to refuse the pipe, since Docker treats a pseudo-terminal and a stream pipe as incompatible.

How do I map a container port so external users can reach my app?

Use the -p flag: docker run -p <host_port>:<container_port> <image>, for example -p 80:5000. This publishes the container's internal port to a port on the Docker host, which is the only way external users can reach the application. Each host port can only be bound to one container at a time, so plan port assignments across all services before running.

How do I onboard a new developer to a Docker stack?

The target state is a single docker run command, or one docker compose up for multi-service stacks. Have the new developer verify Docker Engine is installed, pull each pinned image, then run the stack with the correct -p and -v flags — or simply run the committed Compose file. They never touch the host package manager, so the Matrix from Hell is bypassed entirely regardless of their host OS.

How do I diagnose whether my stack even needs containerising?

Start by listing every service, its required library versions, and the OS it needs, then look for conflicts between services or between a service and the host OS. Each conflicting component is a candidate for its own container. If you see 'it works on my machine' bugs, long setup docs, or version clashes on bare metal, you're looking at the Matrix from Hell — the exact problem Docker solves.

Should I pull images before running them?

It's optional but recommended. Running docker pull <image>:<tag> in advance downloads images so docker run doesn't block on download time — useful for predictable startup and avoiding surprises. In CI pipelines especially, pull explicitly after docker login to stay within rate limits and fail fast on missing or mis-tagged images rather than mid-deploy.

What's the difference between docker stop and docker rm?

docker stop <name|id> halts a running container but leaves it on disk in an exited state, so it still appears in docker ps -a and still references its image. docker rm <name|id> permanently removes a stopped container. You typically stop first, then remove. You can pass multiple IDs to docker rm in one command, and the first few unique characters of an ID are enough to identify it.

// Troubleshooting

Why does my container exit immediately after starting?

A container lives only as long as its main foreground process. If you run a base OS image like Ubuntu with no foreground command, there's no process to keep it alive, so it exits immediately. Containers are meant to run a specific task or process, not to host an operating system. Design each container around a single foreground process.

Why does docker rmi fail to delete my image?

docker rmi fails if any container still references the image — including stopped or exited containers you may have forgotten about. Run docker ps -a to find all hidden dependents, remove them with docker rm <name|id>, then retry docker rmi <image>:<tag>. You must clear every referencing container before an image can be deleted.

Why am I getting 'too many requests' errors when pulling images?

You're hitting Docker Hub's rate limits: 100 unauthenticated pulls per 6 hours per IP, or 200 per 6 hours on the free Personal tier after docker login. CI pipelines sharing an IP hit this quickly. Always run docker login first in CI, or use a paid plan for unlimited pulls. Authenticating raises your limit significantly.

Is a Linux container on Windows truly native?

No. When Docker Desktop runs a Linux container on Windows, it's actually running inside a Linux VM under the host, not as a native Windows container. The kernel-sharing constraint still applies — the container shares the Linux VM's kernel, not Windows'. For learning, running Docker Engine inside a dedicated Linux VM is the recommended path on both Windows and Mac.

// Comparisons

How does Docker Compose differ from plain docker run?

Plain docker run launches a single container with flags typed on the command line, while Docker Compose defines all services, their port mappings, volumes, and inter-service dependencies in a single version-controlled file. For multi-service stacks — a frontend, a database, and a cache, for example — Compose replaces several error-prone docker run commands with one declarative config you can commit and share.

How does a Dockerfile differ from an ops runbook?

A Dockerfile transforms an ops runbook — prose instructions prone to drift and tribal knowledge — into version-controlled, reproducible build instructions jointly owned by developers and operations. Once a developer builds and verifies the image, operations deploys that exact same image unchanged, guaranteeing identical behaviour in production. This is the DevOps artefact that closes the gap between dev and ops.

Do containers replace virtual machines entirely?

No — the model is containers and VMs, not containers or VMs. Use virtualisation to provision and decommission Docker hosts elastically, and use Docker to provision and scale applications rapidly on those hosts. VMs give you kernel-level isolation and infrastructure elasticity; containers give you lightweight, fast application packaging. The two technologies are complementary layers in a modern stack.

// Advanced

Can I run two versions of the same database at once?

Yes. Pull both tagged images — your current stable version and the target upgrade version — then run each with docker run -d, mapping each to a different host port, such as 3306 and 3307. Each container has its own isolated file system and volume mapping, so there are no conflicts. Use docker inspect to confirm each container's network settings and mounts. This is ideal for migrations.

What is docker system prune and is it safe to run?

docker system prune removes all stopped containers, unused networks, dangling images, and unused build cache in one sweep. It's safe and convenient in development environments to reclaim space. On shared or production hosts, use it with caution — it can delete stopped containers and images other users or processes still need. Review what will be removed before confirming.

What are containerd and runC?

containerd and runC are the container runtime components Docker uses under the hood, replacing LXC since version 0.9.0. runC is the OCI-compliant reference implementation that actually spawns and runs containers, while containerd manages the full container lifecycle. They are why containers can share the host kernel while keeping isolated processes, networks, and file systems.