hey i'm cameron mckenzie at cameron mcnz on twitter and i wanted to talk to you about
docker specifically installing it on a fresh clean ubuntu 20.0 instance and then maybe even pulling a
container from docker hub and running it i got the hello world i've also got a special spring
boot micro service i'm going to try and run as well as you can see here i've got a base install
of ubuntu 20.04 and the only thing i've done here is add the terminal to my favorites i put a little
bit of text inside of this text file to guide me through the installation of docker on ubuntu
and i've also got a little firefox browser open to my docker hub account where i've got
a docker container hosted over there called rock paper spring
i thought it might be nice to prove that docker is installed on ubuntu successfully by running
that little spring boot micro service container okay so first things first what do you want to
do well you want to update the app package index and make sure that we can install
all of our components over https so we first do the sudo apt-get update throw my password in there
and once that's done the next line is installing all of these components here as i said this will
allow me to do the update over https so that means installing app transport ca certificates curl
new pg agents some software common properties anyways that all gets in there and it gets done
fairly quickly once that's done we use the curl that we just installed to grab docker's official
gpg key there we go it doesn't take long to download a gpg key once we've got that we
want to grab the stable debs the stable binaries the stable information about docker so we go to
downloads.docker.com i'm on the focal version of ubuntu i want a stable release you could have a
test release you could have a nightly release too and now we're going to add all of the information
about that deb to our local repository this should only take a second and once this completes we're
going to do the sudo apt update once again you can never ever do the sudo apt update too many times
i might even do a little pseudo app cache policy just to see what we've got available to us so
what happens here we've got all sorts of different archives available to you that's too much for me
to even keep track of you know what i'm just going to do the basic install docker ce i'm not going to
specify a version or anything like that i'm going to say sudo apt-get install docker-ce docker cecli
container d dot io and that's going to go ahead and that's going to install docker if i click yes
on that yes no option okay that's complete it might be nice to take a look at the
version of docker that we're running so we'll do a pseudo docker version 20.10.3 i'm pretty happy
with that uh maybe take a little look at the status see if the process is actually running
looks like we've got everything running it's active it's running i'm pretty
happy about that you know anytime you install docker it is customary to do the old docker hello
world so i'm going to do a pseudo docker run hello world hello world is a container hosted over on
docker hub and you see it says hey i can't find this image locally is that first command but it
searches for it it downloads it it says it's pulling it it's pulling it from docker hub
it downloads it and says hey hello from docker that's all it does it's not that interesting but
it proves that things are working it's also cool if you go pseudo docker images you'll notice that
that hello world image is registered now i've got a little container over on docker hub it runs on
port 8080 so i got to do a little razzle dazzle if i want that one to run so i do sudo docker run it
runs internally on port 8080 i'm going to map that to port 80 88 and say hey i want to run my rock
paper scissors container i'll click enter notice it again says can't find cameron mckenzie locally
but there is this one over on dockerhub.com hub.docker.com there's my account and there's
the little repository that we are trying to download it's only going to take a second
you notice there's a spring application you can see the spring banner that just came up there
a second ago i'm going to drag up there to see if we can see it just to prove what it is you can see
spring there see some references to hibernate and jpa in there because that spring boot applications
uses that for a little bit of persistence only took about seven and a half seconds
for that to run and now let's see if we can run that locally in our browser so it's localhost
colon8080 and of course i mapped it to localhost 8088 and so you got to have the right port mapping
otherwise of course it's not going to work and there we go index.html like i had originally
except i didn't have the right port number and then there's our little rock paper scissors game
so can we play the game we can keep playing rock paper and scissors if you can figure out the trick
well you can win every time but there you go that's a little spring boot application running
in docker pulled from docker hub all within just about five minutes doing the installation
and that's about it and there you go that's how easy it is to install docker on ubuntu
20 and run a couple of containers from docker hub including the hello world and a beautiful
little rock paper scissors done with a spring boot now if you enjoyed that tutorial i want
you to head over to the server side dot com i'm the editor in chief over there we've got
lots of great tutorials on spring docker devops you name it if you're interested in my personal
antics you can always follow me on twitter at cameronmcnz and subscribe on the youtube