- [Instructor] Installing Docker on Linux
is much more straightforward than other platforms.
Since it's just another program on Linux,
you can go ahead and just install it like any other program.
I'm running Ubuntu,
so I'm going to search for installing Docker on Ubuntu,
and head on over to the official Docker installation guide
for Docker Ubuntu.
If you're running Red Hat or one of the other distributions,
the process will be very similar,
but you'll land on a different page.
OK, the first thing I'm going to do is check
that I meet the requirements.
Most modern Linux systems will.
If you have previously installed versions of Docker
that aren't called docker-ce,
go ahead and remove all those previous versions.
Trust me, Docker CE is much more modern
and going to work better for you.
OK, the first thing we're going to do
is make sure our system has its dependencies
generally up to date.
I'm going to Copy, switch over to a Terminal,
and Paste it in.
Now that I've got that, we're going to go ahead
and install the dependencies that need to be in place
before we can add the Docker organization
as a source of software for our computer.
Copy,
Paste.
We want to install https transport,
a bunch of certificate authorities,
make sure we have curl for one of the steps later on,
and a collection of generally useful software,
software-properties-common.
If your computer tells you these are already installed,
then that's good, you're good to go.
Now that that's done, this is an important step.
I'm going to go ahead and tell my system
that it should trust software provided
by the Docker organization.
Copy,
Paste it in.
What this is going to do
is fetch the cryptographic signing key
of the Docker organization from them,
and tell my computer to import this as a key
that is trusted to provide software to this system,
so it's going to download the key,
then over here, it's going to take the contents of that key
and pipe it to the apt-key command,
which adds a trusted source.
Remember the dash at the end of the command,
if you're pasting it in and it doesn't work,
sometimes it's because that got left off.
OK, and now the next important step
is to add the Docker organization
as a source of software for this computer.
Go ahead and Copy that command, Paste it in.
What this does is it's calling apt-add-repository,
which adds an official source of software,
saying we're going to add a source of Debian packages
for the, in this case, amd64 architecture,
that's almost certainly what you'll be using.
Then the URL of where Docker provides their software.
This little bit here, the lsb_release command
inside a subshell, is just a little bit of shell magic
to automatically detect which version of Ubuntu
your system is running and fetch the appropriate packages.
OK, now with all that out of the way,
we're very nearly done.
I'm going to go ahead and refresh the dependencies again.
Apt-get update, remember the sudo.
Now the magic moment.
Apt-get install docker-ce.
With that done, for most people and most purposes,
you're done with this guide.
If you need a specific version of Docker
for compatibility with something else,
then you can keep going.
Now, let's see if it works,
docker run hello-world.
I need to add my user to the list of users
who are allowed to run Docker
without putting sudo at the beginning.
If I take that same command and put sudo docker run,
then, voila, I see it go.
But that's not very convenient.
Let's go ahead and make that work.
Scrolling down to the bottom here, under Next Steps,
there's a Post installation guide,
clicking on that and scrolling down
to the Manage Docker as a non-root user,
all we have to do is run a couple of commands here,
Copy, Paste, I'm going to create a group
for running Docker commands.
It's OK if it already exists.
Then, Paste,
then I'm going to go ahead
and add my user to that group.
$USER here will be resolved by the shell
to the user name you're logged in as right now.
OK, this next step gets a lot of people.
You need to do something that causes you
to get a new login context
before the group changes take effect.
The easiest way to do this is to log out
and log back in again.
Log Out.
Open up my Terminal,
and I'm going to run docker run hello-world, go.
There we have it, Docker started up a container,
ran a process called hello-world
that introduces you to Docker, and then was done.
It's working.