Course outline · 0% complete

0/29 lessons0%

Course overview →

Tags, push, and pull

lesson 6-1 · ~12 min · 17/29

Quiz

Warm-up from lesson 3-1: what did the -t in `docker build -t myapp:v1 .` do?

Registries

So far your image exists only on the machine that built it, which means nothing else can run it: not the server you deploy to, not a teammate, not the test automation of unit 7. Moving images between machines is what a registry is for: a server that stores and serves images, git-hosting for images instead of code. You already used one: docker run hello-world in lesson 2-1 pulled from Docker Hub, the default public registry. The other one you will meet constantly is GitHub Container Registry (GHCR), which lives next to your repos.

A full image reference has up to four parts:

ghcr.io/ada/shop:v2
└─────┘ └─┘ └──┘ └┘
registry owner name tag

When you write just nginx, Docker fills in the defaults: docker.io/library/nginx:latest.

Shipping an image is three commands:

docker login ghcr.io                      # authenticate once
docker tag myapp:v1 ghcr.io/ada/shop:v1   # give the image its full remote name
docker push ghcr.io/ada/shop:v1           # upload it

And any other machine runs docker pull ghcr.io/ada/shop:v1. Thanks to layers (lesson 3-2), pushes and pulls only transfer layers the other side doesn't already have.

Code exercise · bash

Your turn: image references are just strings. Using the two variables, print the full reference for the v2 tag on the first line, then the same repo with the latest tag on the second line.

Quiz

What is actually special about the `latest` tag?

Quiz

You write plain `nginx` in a docker run command. What full reference does Docker actually use?

Problem

Which docker subcommand uploads a tagged image from your machine to a registry?