Docker

From ForcaWiki, the simple encyclopedia

Docker
In one sentenceA tool that packs a computer program and everything it needs into a sealed box called a container, so it runs the same way on almost any computer.
CategorySoftware
RelatedVirtual Machines, Operating Systems, Cloud Computing

Imagine you bake amazing cookies at home, but when you try the same recipe at a friend's house they come out all wrong. Their oven runs hotter, they are missing an ingredient, and their measuring cups are a funny size. Computer programs have this exact same problem. A program can work perfectly on the computer where it was built, then break on a different computer that has different settings or is missing something it needs. Programmers even joke about it: "well, it works on my machine!"

Docker is a tool that fixes this. It packs a program together with everything it needs to run, its files, its helper tools, and its settings, into one sealed bundle called a "container." Because the container carries its own supplies, it runs the same way on almost any computer, whether that is a laptop, a giant server in a data center, or the cloud.

Why is it called Docker?

The name comes from the docks where huge ships are loaded. Long ago, loading a ship was a nightmare, because the cargo was every shape you can think of: barrels, sacks, crates, and odd boxes all had to be packed by hand. Then people invented the standard shipping container, a metal box that is always the same size. Suddenly any crane, truck, or ship could move any container without caring what was inside it.

Docker does the same trick for software. It does not matter what is inside the container, whether it is a game, a website, or a calculator. As long as a computer can run Docker, it can run the container. That is also why Docker's mascot is a friendly blue whale carrying a stack of containers on its back.

What is inside a container?

Think of a container like a lunchbox that holds not just the sandwich but also the plate, the fork, the napkin, and the little salt packet. Everything the meal needs is right there in the box. A software container works the same way: it holds the program plus all the smaller programs and files it leans on, so nothing is missing when you open it somewhere new.

To build a container, Docker first makes something called an "image," which is like a recipe or a blueprint. You can stamp out as many containers as you want from a single image, the same way you can bake a whole batch of identical cookies from one recipe. People share their images on the internet, so instead of building one from scratch you can often grab a ready made one that someone else already prepared.

How is this different from copying a whole computer?

An older way to solve the "works on my machine" problem was to create a pretend computer inside your real computer, called a virtual machine. That works, but it is heavy and slow, a bit like building a whole extra house inside your house just to get one clean room.

A Docker container is much lighter. Instead of a whole new house, it is more like a sealed room that still shares the main house's power and plumbing. Because containers share the real computer's engine, its operating system, instead of copying the whole thing, they can start up in seconds, and one computer can run many containers at once.

How to use it

Docker works best on a real computer rather than a tablet, and you will need a grown up's help to install it. Here is the simplest way to see it work:

  1. Install Docker Desktop from the official website, docker.com. This is the engine that runs all your containers, like setting up the oven before you can bake anything.
  2. Open a "terminal," which is a plain window where you type instructions to the computer instead of clicking buttons.
  3. Type docker run hello-world and press Enter. Docker downloads a tiny ready made container and runs it.
  4. Look for the message that says "Hello from Docker!" If you see it, everything is working.
  5. Now try a container that keeps running, like a small web page, by typing docker run -p 8080:80 nginx. Then open http://localhost:8080 in your web browser to see the page it is serving.
  6. Type docker ps to list the containers running right now, and docker stop followed by a container's name to switch one off when you are done.

Fun facts

  • Docker first appeared in 2013 and caught on incredibly fast, because it made sharing and running programs so much easier.
  • Docker's whale mascot has a name: Moby Dock.
  • Big websites you use every day often run inside thousands of containers at the same time, quietly starting and stopping as more or fewer people show up.