Learn / Lessons · Docker

Docker basics

AI software often comes in containers. What are they? With Server AI Hub, every container on your DGX Spark is on one screen.

Chapters

  1. 0:00Introduction
  2. 0:05With Server AI Hub: One screen
  3. 0:17What you gain: The benefits
  4. 0:26The alternative: By hand
  5. 0:34Where this fits: The AI stack
  6. 0:38First things first: What's a container?
  7. 0:49Picture it: Like a shipping container
  8. 1:03Why bother: Why use containers?
  9. 1:12The tool: What is Docker?
  10. 1:20Try one: Run your first
  11. 1:40Get it: Install Docker
  12. 1:50Every day: Run an app
  13. 1:58Choose well: Pick trusted images
  14. 2:07Images: What's in an image?
  15. 2:17From image to container: One recipe, many copies
  16. 2:22Moving it: From here to there
  17. 2:32The small print: What doesn't travel
  18. 2:52Compare: Not a virtual machine
  19. 3:01Your data: Keep it in a volume
  20. 3:10Recap: You've got it
  21. 3:13Wrap up
Read the transcript

Introduction

AI software often comes in containers. What are they?

With Server AI Hub: One screen

With Server AI Hub, every container on your DGX Spark is on one screen. Start, stop or restart one with a button, and read its log without opening a Terminal.

What you gain: The benefits

You see what's running, and what each one uses. Everyday fixes take a click. And with two Sparks, both are on the same screen.

The alternative: By hand

The other way is by hand, with Docker commands in a Terminal. It's worth knowing, because it's what happens underneath. Here's how.

Where this fits: The AI stack

Today's block: containers.

First things first: What's a container?

A container is a program running in its own walled-off space. It has its own files and libraries, and its own network view, while sharing the computer's kernel.

Picture it: Like a shipping container

Picture a shipping container. Ships, cranes and lorries can handle this standard box without caring what's inside. Software containers share that idea. But the computer needs software to run them, made for its processor.

Why bother: Why use containers?

Why use them? The app's needs come with it. Versions don't clash. Each is walled off. Fresh starts are easy.

The tool: What is Docker?

Docker is a popular tool for containers. Build a package called an image, share it, and run it.

Try one: Run your first

A Terminal is a window where you type commands. Type docker run hello world. Docker fetches a tiny test image from Docker Hub, an online store, and prints a hello message. If it says permission denied, your account isn't allowed to use Docker yet. Only run images from publishers you trust.

docker run hello-world

Get it: Install Docker

On a Mac or Windows PC, install Docker Desktop. On Linux, follow Docker's install guide. A DGX Spark has it already.

Every day: Run an app

Run a web server in the background on a port. List what's running. Then stop it and remove it.

docker run -d -p 127.0.0.1:8080:80 \
  --name web nginx
docker ps
docker stop web && docker rm web

Choose well: Pick trusted images

Look for Docker Official Images and Verified Publishers. Pick a version tag. Read the image's page before you run it.

Images: What's in an image?

An image holds system files, a language runtime, libraries and other dependencies, plus code and a start command. It doesn't change.

From image to container: One recipe, many copies

Start an image to get a container. One image can start several.

Moving it: From here to there

Build on one machine, push to a registry, a store for images, then pull it onto your DGX Spark. Its dependencies travel inside.

The small print: What doesn't travel

There are limits. The other machine needs Docker. The image must suit its processor. The Spark uses Arm, so an image built only for x86 won't just run. For the GPU, add the NVIDIA driver and Container Toolkit. And data in a volume doesn't travel with the image.

Compare: Not a virtual machine

A virtual machine starts a whole system, with its own kernel. Containers share the computer's kernel: lighter, but less separated.

Your data: Keep it in a volume

Keep data in a volume, outside the container. Remove the container, and a named volume stays. Still back it up.

Recap: You've got it

Pack it once, run it where it fits.

Wrap up

So learn the ideas, and let Server AI Hub do the daily work: no commands to remember, every container in view, and a question before anything is force killed.

Sources

More lessons