Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
One of the main reasons to move your app into a Docker image is to make it easy to share it with others. But you don't have to upload image files to Dropbox or publish them on a website. Registries provide a standardized way to share Docker images, kind of like Git repositories. With a Docker registry, you can upload images, and your users can download them and run them as containers with just a few simple commands.
One of the main reasons to move
your app into a Docker image
0:00
is to make it easy to share with others.
0:03
But you don't have to upload image files
to Dropbox or publish them on a website.
0:05
Registries provide a standardized
way to share Docker images,
0:10
kind of like Git repositories.
0:14
With a Docker registry,
you can upload images and
0:16
your users can download them
with just a few simple commands.
0:20
The docker login subcommand lets
you connect to a docker registry.
0:24
By default, it'll connect to Docker Hub, a
public registry that offers both free and
0:29
paid plans,
kind of like GitHub does with git repos.
0:35
You'll be prompted to visit
hub.docker.com to create an account
0:38
if you don't already have one.
0:42
I've already created an account so I'll
use my username, And password to log in.
0:43
Let´s upload the mongodb image,
that we created earlier.
0:51
We do that with the docker
push sub-command.
0:56
We need to specify the name of
the image we want to upload.
0:59
Mongodb.
1:03
When we hit enter,
1:05
Docker will try to upload the image to
our repository named library/mongodb.
1:07
There is a problem though,
we don't own the library repository and
1:12
don't have access.
1:16
We'll need to retag the image using a
repository name that we do have access to.
1:17
Fortunately that's really easy.
1:22
An image can have many tags, we'll just
add another tag to our existing image.
1:25
We can do that with
the docker tag subcommand.
1:29
We provide the existing name for
the image, mongodb, followed by a new tag.
1:34
Docker Hub requires that images start
with the Docker Hub username, so
1:40
I'll use mine, dockern00b.
1:44
Followed by a slash and
then the name I want to use for
1:46
this particular image, mongodb.
1:51
When we hit Enter, the new tag will
be added to the existing image.
1:54
Now let's try uploading it,
using the new tag,
1:59
docker push dockern00b/mongodb.
2:05
This time the upload
will be successful and
2:10
our image will be stored
on the docker registry.
2:12
With our image successfully uploaded,
our users will be able to download and
2:19
launch it as long as they
have docker installed.
2:23
If it's a public repository, they don't
even need to be logged into docker hub.
2:26
You can pull images from a docker
registry with the docker pull subcommand.
2:30
We need to provide the repository
name that it was uploaded with,
2:36
dockern00b/mongodb.
2:42
Docker will connect to docker hub and
download the image,
2:46
when the download is complete,
the'll be able to run it with docker run.
2:50
As always for this image,
They need to publish port 27017.
2:54
So we'll run Docker, run -p 27017
2:58
publish support 27017 and
3:04
end with the image name,
dockernoob/mongodb.
3:08
So with the container running
we can run the mongo command and
3:19
we'll be able to connect successfully.
3:23
Docker registries let you manage images,
collaborate with co-workers,
3:26
or simply manage the images you
use locally for side projects.
3:30
Docker is optimized for
version control of images.
3:34
And wherever possible,
3:37
will avoid redownloading parts
of images that it already has.
3:39
Now we've covered how to manage images and
containers from the command line.
3:43
In the final stage, we'll build a Node.js
app from scratch, build an image for
3:47
it, run it as a container, and test it.
3:52
And at the end of the course we'll
recommend some next steps that will help
3:54
you simplify operations and
development using docker.
3:58
You need to sign up for Treehouse in order to download course files.
Sign up