- [Narrator] As we start exploring building larger
systems with Docker,
one of the first questions that often comes up is,
"Where's my data?", "Is it safe?"
Many companies choose to run their own
Docker Registry so they can know that their data
is safe and somewhere they can protect it.
So, it's just a program.
You can run it anywhere you run other programs
using existing infrastructure.
It stores layers, images, keeps track of them,
stores the tags,
generally the meta data around the images,
along with the images,
and it's just a service that listens on port 5000
for instructions like,
push this image,
pull that image,
load this image from a disk,
or search for images containing these key words.
It also keeps track of who's allowed to log in,
provided that you've configured that.
There are a couple of popular choices.
There's an official Docker Registry produced
by Docker, the company,
and the popular maven caching repo, Nexus.
Also happens to provide in the newest versions,
a Docker repo built in,
so there's a good chance you already have a
Docker Registry running in your organization
and nobody's using it.
Now since the Registry is just a program,
designed to provide a network service,
why not go ahead and run it in Docker?
So Docker makes installing network services pretty easy,
that's what it's for,
and the Registry is a network service.
So let's just run it in Docker.
All we have to do is Docker run,
dash d for detach, which we've seen,
and I want to expose port 5000 in the Registry,
to port 5000 on my local machine.
This is a new argument,
- -restart always says if this container
dies, just restart it immediately.
We give it a name registry so I can keep track of it,
and the image to use is called registry.
Version two is current.
Okay, now it's running.
Now, just to show what this does,
let's push something to it.
So the first thing I'm going to do is add a tag
to my image to associate it with the local registry
that I've just started.
So I'm going to run Docker tag.
I'm going to take my ubuntu:14.04 image that
I happen to have locally.
You can choose any image you like,
and I'm going to tag it with first,
the name of the server running the registry,
which in this case is localhost,
and I'm running it on port 5000, slash,
a name for the organization or name space.
I chose my company and the image name is
my-ubuntu version 99.
Now I'm going to go ahead and push it to my registry.
Now I have a copy of my unbuntu image saved locally,
so regardless of what happens to the official version,
I'll always have a copy of this one.
Having saved things locally has really saved me
a couple of times,
when images I depended on disappeared from the main repo.
One thing to note,
you must must set up authentication and security
on this registry before you expose it to any network,
especially the internet.
To do that, head on over to the official Docker
Registry documentation page.
Give the introductory material a little once over,
and then head over to the deployment instructions.
For details on setting up authentication, and choosing
where your registry is going to permanently store
its data.
There are several options for preserving your images.
One of them is just store it on the same machine
that's running the registry.
If you have that machine backed up,
good solid back up regime, this works fine.
Other great options include the Docker Trusted
Registry made by the people who make Docker,
or if you're on the Amazon ecosystem,
the Elastic Container Registry integrates nicely
with the rest of the AWS services,
and Google provides the Google Cloud Container Registry
which tightly integrates with the rest of the
Google ecosystem,
and on the Microsoft side of things, there's the
Azure Container Registry which is an excellent
option for services that need to integrate with
other things using Microsoft Azure.
Another important option is saving and loading your
images locally without using a registry at all.
Docker offers a pair of commands, docker save,
and docker load that do the obvious thing.
So let's take a look at the images I have here.
Now I'm going to save my most important images
into an archive so that I'll have them available.
Docker save -o for output, then the file name.
I'm naming the file my images.tar.gz,
and I'm going to put the images debian:sid
busybox and ubunto:14.04 in there.
Debian:sid, busybox and since I didn't specify a tag
it will use latest and ubuntu,
ubunto14.04,
okay.
Saving your images locally is a great way to make
them available when you're traveling,
making backups,
and a good way to ship images to customers,
and never underestimate the bandwidth of a 747
full of Docker images on backup tapes.
So now, to show that that actually works, let's
go ahead and delete my local copy of those images.
We see that they're gone,
and now I'm going to say docker load -i for input,
my images.tar.gz
docker images and we can see they're back.
The docker save and load commands are also very
important for allowing you to move images between
storage types on the same server.
If you switch back end storage engines in Docker,
you have to save the images out
then load them back in after switching,
and it's also a really good way to get your
images to other people
literally by mailing them.