So we now know what containers are,
and that Docker helps us create these containers.
I also already outlined some advantages.
But still, you might wonder,
why exactly do we need containers in software development?
Maybe the example made sense for a picnic basket?
And to some extent, it makes sense
for a software development.
But is it really that important that useful?
Yes, it is, we should just ask ourselves
one simple question.
Why would we want independent standardized application
packages in software development?
Well, for one, one very good and typical example.
And one of the main use cases of Docker,
I would say, We of course, often have different development
and production environments.
And here's a simple example.
Let's say you created a Node.js application.
And you wrote some code there,
which requires Node.js version 14.3
to run successfully.
And this is not some made up example.
The example you see here is Node.js code,
which uses a feature called top level await.
Now you don't need to know Node.js to follow along
with this course, for the moment, it's enough to know that
this is a feature, which would not work
in older versions of Node.js .
We need Node.js 14.3 or higher to execute
this code successfully.
The problem is that we might have that version installed
on our local environment, on our development environment,
on our local machine.
But if we then take this application,
and we deploy it onto some remote machine onto a server,
where it should be hosted, so that the entire world
can reach it, then on that remote machine,
we might have an older version of Node.js installed,
maybe 14.1, or 12, or eight, whatever.
And all of a sudden, the code which worked locally
on our machine doesn't work there anymore.
And depending on what's going wrong,
it can take quite some time to figure out what
the problem was.
So having the same and with that,
I really mean, the exact same development environment,
as we have it in production can be worth a lot.
And that is something where Docker
and containers can help you,
you can lock a specific Node version
into your Docker container, and therefore ensure
that your code is always executed with that exact version.
And all of a sudden, that potential problem is gone
and can't occur anymore.
Because your application runs in that container,
which brings its own Node.js version.
So that's one example.
Kind of related to that would be another example,
different development environments within a team
or a company.
Let's say we're in a big team.
I'm working there, and you are working there.
And now we're working on the same project,
for example, that same Node.js application again.
Now because you haven't worked with Node for some time,
or because you didn't need to update,
you still have an older version of Node.js installed
on your system.
And I have the latest version.
So I wrote this code with top level await.
And when I share the code with you,
it doesn't work for you.
Now, obviously, you might say,
updating Node.js is no problem,
I can easily update it on my system.
And we're on the same page again.
Yes, but for one, it's just one example.
There could be more complex projects with more complex
dependencies which you need to manage and install.
And in addition, even in that, one example,
it's still annoying that we're not able to work on the same
code base together, and we have some guarantee
that it will always work.
And that we always use the same environment.
We want that reproducibility in software development,
and therefore even here, if we're not deploying
it at the moment, having that locked in environment
with everything the code needs in the container
can be worth a lot.
And now last but not least, even if you're working
on your own, then still Docker and containers
could be very useful.
Because if you have multiple projects on which you're
working, then you might have clashing versions.
Let's say one project uses Python version two still
for whatever reason, another project uses the latest
version of Python.
The same maybe with Node.js or PHP
or whatever kinds of projects.
There you would have clashing versions,
and that means that whenever you switch
from project A to project B, you have to uninstalled
the wrong version and install the right version.
For example, if one project needs Node version 12,
the other project needs Node version 14.
If you switch project, you have to uninstalled version 14
installed version 12 instead, and vice versa.
So switching between projects becomes a big hassle,
and is no fun at all.
And that, again is something where Docker
and containers can help us.
We lock our versions into the containers,
and every project has its own container.
And therefore if we then switch projects,
it'll just work like that.
We don't need to uninstall and reinstall anything
because it's all in the container,
not globally on our host machine.
And they have first switching projects becomes as easy
as launching a different container.
And these are all things we're going to see throughout
this course.
And you're going to learn everything you need to solve these
problems throughout the course.
And that's why we might wanna consider working
with containers and why Docker is quite helpful tool.