“Container Adventures: Hiro and Yumi Explore the World of Docker”

Hello Friend
A developer, Hiro, working on his laptop, looking like he's about to pull his hair out.

We see a developer, Hiro, working on his laptop, looking like he’s about to pull his hair out. A colleague, Yumi, approaches him and asks what’s wrong. Hiro explains that he can’t seem to get his application to run on different machines, and he’s starting to lose his mind.

docker run -it -v /path/to/app:/app image-name

Hello Friend
It can transport your application anywhere, no matter how crazy the destination.

Yumi looks at Hiro sympathetically and suggests he try using Docker containers. She explains that Docker is like a shipping container, it can transport your application anywhere, no matter how crazy the destination.

docker build -t image-name .

Hello Friend
Yumi in a sailor's hat, using a crane to lift a shipping container with Hiro's application inside.

Hiro looks a little confused and asks Yumi how a shipping container is supposed to help him. Suddenly, we see Yumi in a sailor’s hat, using a crane to lift a shipping container with Hiro’s application inside. She shouts back at Hiro, “Don’t worry, Hiro, we’ll ship your app to the moon if we have to!”

docker push image-name

Hello Friend
Yumi pulls out a tiny boat, and tells Hiro he can start with a 'docker dinghy'.

Hiro blinks, then bursts out laughing. He asks Yumi how to get started with this crazy shipping container technology. Yumi pulls out a tiny boat, and tells Hiro he can start with a “docker dinghy”. Hiro looks at the tiny boat skeptically, but decides to give it a try.

docker run -d -p 80:80 --name container-name image-name

Hello Friend
Hiro floating in the docker dinghy, surrounded by giant shipping containers.

We see Hiro floating in the docker dinghy, surrounded by giant shipping containers. Yumi, who has now put on a captain’s hat, is shouting instructions to him through a megaphone. “Turn left at the nginx container, then go straight until you see the postgres container!”

docker run -v /path/to/app:/app \
  --network my-network \
  -e DATABASE_URL=postgres://username:password@postgres:5432/my-db \
  -p 8080:8080 \
  -d myapp:latest

docker run -v /path/to/app:/app \
  --network my-network \
  -p 8080:80 \
  -d nginx:latest

docker run --network my-network \
  -e POSTGRES_PASSWORD=password \
  -e POSTGRES_USER=username \
  -e POSTGRES_DB=my-db \
  -d postgres:latest
Hello Friend
Yumi pops up behind him, holding a giant beach umbrella.

Hiro finally reaches his destination, a small island in the middle of the ocean. He’s relieved to find that his application is running perfectly on the island’s only computer. Yumi pops up behind him, holding a giant beach umbrella. “Welcome to your new office, Hiro!” she exclaims. Hiro looks at her, then at the shipping containers surrounding him, and shakes his head in disbelief.

> docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED          STATUS          PORTS                  NAMES
53e2761b7a78   nginx:latest    "/docker-entrypoint.…"   30 seconds ago    Up 28 seconds   0.0.0.0:8080->80/tcp   mystifying_hamilton
3e5d9388d1c9   postgres:latest "docker-entrypoint.s…"   30 seconds ago    Up 28 seconds   5432/tcp               pensive_meninsky
3e5d9388d1c9   myapp:latest    "docker-entrypoint.s…"   30 seconds ago    Up 28 seconds   0.0.0.0:8080->8080/tcp apple_banana
Hello Friend
Yumi to the rescue.