ALEXIS MP: So hi, everyone.
Welcome back.
Today, the topic is Docker-- in the cloud,
on the desktop, Docker everywhere.
And I'm speaking with David today.
So what do you want to show us today?
DAVID GAGEOT: I'd like to show you
how easy it is to package a Java 8 application, a web
application, on your laptop with Docker, and use this package
application to deploy it on that platform.
ALEXIS MP: So what we're trying to demonstrate here
is the fact that you're able to build an environment which
will be running on your development environment,
and use the exact same environment, packaged
as a container, with the Docker technology,
and ship this across to the cloud and computer.
DAVID GAGEOT: Yes.
It is exactly like a big binary file.
But inside this binary, there's your application.
There's also all the dependencies.
The Java 8 version, the operating system.
Everything is fixed, and you can run it
on the machine or the cloud with the same command.
ALEXIS MP: Sounds promising, I think.
It's quite useful.
Why is it actually useful to have this same environment
across--
DAVID GAGEOT: It works on my machine.
It doesn't work on production, it works on my machine.
So this is one of the reasons why Docker is very useful.
You can reproduce exactly the same environment
on your machine as on production.
It's especially very important if in operation, you've
got multiple servers, load balancer, different components.
So you can reproduce exactly the same environment
on your machine with different containers.
You could do it with VMs, but then on your machine,
you would run lots of VMs.
It would be too much for your machine.
With containers, it's very lightweight.
Very easy.
ALEXIS MP: OK.
Let's get going and let's look at the demo
you have prepared for us.
DAVID GAGEOT: OK, so I've prepared a very small project
with a single file called Dockerfile.
This Dockerfile is the recipe to build my container.
So I will show you the Dockerfile very quickly,
and then we'll run it, and we'll come back to the Dockerfile
to see what it contains.
Let's create the container from this Dockerfile.
It's like a recipe to make a cake.
So that's build a cake.
Here it is.
It will download lots of things, install
lots of things inside the container.
Let's take a look at the Dockerfile.
So what I'm saying is my container is based on Ubunto.
And then I will install lots of components, mainly Java 8.
I will install Maven, Git.
Then I will clone the source code of my project,
build it inside the container to be sure
that the build is easy to reproduce.
And what is very important is at the end of the build,
I've got classical Maven install.
Here's the command that the container will run.
So classical Java application.
ALEXIS MP: So it is definitely a recipe.
You are building everything from zero.
So hopefully the recipe will always produce the same cake.
DAVID GAGEOT: Yes.
Not always.
In fact, if I run the same recipe in two weeks,
the version of each components might change.
So I could fix the versions inside my recipe.
But then, at the end of the day, Docker
is not really based on you running the same recipe again
and again.
You run the recipe once, and then you've
got a binary that you can run on your machine
or run on another machine.
ALEXIS MP: And there are ways to share
this with different people, if you-- even
a common repository for people to use.
DAVID GAGEOT: Exactly, you can.
It's like a battery.
So you can copy it, or you can publish it
in public or private repositories.
There's lots of ways to share container images.
What we will do is we will use the recipe
to build locally and build on the cloud platform.
It's not the thing you will do normally,
but it's just to show you that it's
the same locally and on the cloud platform.
ALEXIS MP: Great.
So it takes a few minutes to build locally on the laptop,
so we'll just skip ahead and get to a point
where we're about to finish the build.
DAVID GAGEOT: So here we are.
We're running the last Maven build.
And at the end, it will produce the Java flies that we need.
And we'll be able to launch the container
and see if the application runs properly.
ALEXIS MP: Great.
So tests are going.
And as soon as the tests pass, I suppose you have-- no tests.
Wait.
DAVID GAGEOT: It's not me.
Yes.
Here it is.
So build success, and then the container is ready.
What I want to show-- you said, can we use the same respect
to build a container twice?
Docker uses a cache to make sure that, if on the same machine
you build from the same recipe, it will use cache
again and again so that you don't
run all the steps of your recipe again and again.
So you should change an operation
at the end of your recipe, it will
reuse the cache for all the operations before the change.
So let's try to run our container.
What we are going to do is to ask for the version of Java
inside the container.
ALEXIS MP: Just to make sure we're using the right one.
That's one thing you can try to check.
DAVID GAGEOT: Yes, to make sure that it works properly.
So we saw the Docker build an operation,
so now we're going to use the Docker run.
So we run the same container with a command, java -version.
And we see that we've got Java 8 installed inside the container.
If I run the same command on my machine, I've got only Java 7.
So this is to show you that you can use different versions.
ALEXIS MP: They're completely isolated.
DAVID GAGEOT: Yes, completely.
So now we can try to run the real applications
by letting the container use the default command.
And here it is.
Our website is running.
Yeah.
ALEXIS MP: So you build all of this locally
and you have something that's working.
So now we can ship it-- that's probably
the best way to describe it-- to the cloud.
DAVID GAGEOT: Yes.
Just before, let's try to open it
into a brother to make sure that it works property.
So we're going to run the container-- Oh.
What's going on is I've got other containers running
on the same port.
So I'm going to delete all my running containers.
It's like deleting running processes.
I just kill them, and then run my process again.
And now it's running as a daemon in the background.
So we open a URL and see that the site is running properly.
Yes.
ALEXIS MP: That's great.
Perfect.
DAVID GAGEOT: As you say, now let's ship it.
So we're going to ship it to deploy it
on Google Compute Engine.
So we're going to open the Google Compute Engine console.
And we're going to create a VM on which we're
going to install Docker.
And then we're going to build the same container
from the same recipe.
ALEXIS MP: So we're really starting from scratch.
DAVID GAGEOT: Yes, from scratch.
Choose the name, allow HTTP traffic.
Choose the zone of our VM.
We can choose among different type of machines.
I'll keep the default one.
I'm going to choose a Debian from my machine.
So everything I do here on website,
I could do through the API with a command line.
Here it is.
Here's the command line you could run to do it.
ALEXIS MP: Especially if you want
to instantiate multiple VMs with the same configuration.
DAVID GAGEOT: What I like about Google Cloud
platform is I can always click on a link
to show me the command I'm going to execute from the website.
That's nice.
So I can see that the VM is created.
That was quick.
And I'm going to SSH into the VM using the command given
by the website.
I could use a standard SSH, it's just that here there's
a wrapper that uses the correct configuration, security
configuration mainly.
We have to wait for the VM to boot.
ALEXIS MP: Shouldn't take too long.
DAVID GAGEOT: Here it is.
Yes.
So I'm in the machine.
Maybe 15 seconds to make it run.
Docker is not installed.
I'm going to install Docker.
So it takes about 20 seconds.
I need to [INAUDIBLE] the line to install it on the machine.
ALEXIS MP: Yeah, it's probably interesting to see
how it's being installed, but there
are other options where it comes, maybe,
packaged as part of the image.
DAVID GAGEOT: I could package it myself.
I can install it on Google Base image and create a new image.
Or I could use the images provided
by Google that already have Docker installed.
So I've got lots of options.
Here it will download Docker, install it,
make sure it works properly.
OK, docker was installed.
It started, and now--
ALEXIS MP: It's going through a few tests, just to make sure.
DAVID GAGEOT: Yes.
It will run a basic container to make sure it works property.
Then I have to add the current user to the dock group
to make sure I can run Docker without sudo.
Here it is.
Let's run docker ps to see what's running.
Nothing, normal.
So I'm going to build the same image from the same recipe.
This time the recipe is not locally on my machine,
it was published on Github.
So I'll just give the URL to Github.
And the Dockerfile will be downloaded and used
to build a container.
And so I will see the exact same step on my local machine.
It will download it too, install Java 8,
extract and build the application.
It will be ready to run.
ALEXIS MP: Yeah, so maybe a little
bit faster, because the network is somewhat faster.
But other than that, it's very similar.
So we'll skip ahead and get to the point
where it's almost ready to finish building.
DAVID GAGEOT: Here it is.
So the build is running.
And done.
The container is ready to run.
So let's make sure that it runs properly.
We'll use the docker run command again.
ALEXIS MP: So it happens to be the exact same command,
but you could map it to a different port
if you wanted to.
DAVID GAGEOT: Same version of Java as on my machine.
And then I can run the real web application in the background.
Done.
And I can check that everything is running properly
by opening the IP of my VM, and it works.
ALEXIS MP: Great.
So we've successfully shipped something from the laptop
to the cloud, and it behaves exactly
in the same way, which is what we were trying to demonstrate.
That's a good thing.
Great, so that worked.
That's very good.
We were trying to demonstrate something.
Shipping, building, and behaving the exact same way
on both environments.
And you can have that on many different environments.
So, by the way, you were doing a demo
on Mac, which required a little bit of setup.
You want to--
DAVID GAGEOT: Yes.
It uses a component called Boot2docker.
Boot2docker is a very lightweight VM
that is running Linux.
And it is used to run the Docker daemon on my laptop.
On the Google Cloud platform, this
is Debian, so it's running natively.
But on my machine, it's the only way to make it run.
ALEXIS MP: Great, so that was very interesting.
One key element, obviously, here is the Dockerfile itself,
which is somewhat of the recipe.
Who writes the Dockerfile, in your experience?
Who should write it?
DAVID GAGEOT: I think that it's mainly
the developer that writes the Dockerfile.
But you've seen on Dockerfile that you
can base your Dockerfile from another container.
So this container is base container.
It could be [INAUDIBLE], Ubuntu, or Debian.
Or it could be a base container that you
developed with an operation.
So you choose a base container for all your applications,
and then the developer writes the Dockerfile
for each application.
ALEXIS MP: Great.
So would you recommend using Docker today?
On development environment, on production environment,
maybe on Compute Engine, specifically?
DAVID GAGEOT: I do it every day for my customers.
There's a lot of big companies using Docker already.
So it's really a production ready, so try it.
Give it a try, and you'll be happy, I think.
ALEXIS MP: And try it for yourself.
You've probably heard of Docker before.
Now is a good time to try, and you
could do this on the Cloud platform,
and Compute Engine, specifically,
following something similar to what David showed us today.
So thank you, David.
DAVID GAGEOT: Thank you.
ALEXIS MP: Thanks for coming, and I'll be seeing you soon.
Cheers.