-: When it comes to the Docker core concepts,
there are essentially two core concepts
you have to be aware of.
Containers and images.
Now, containers are these isolated boxes,
which contain our code,
and the environment needed to run that code.
And every container,
and that's really important,
is focused one task typically,
which means we don't do multiple things
in one container.
We either run a web server,
or we run a front end,
or we run a database.
But we don't all these things in one container.
The idea of course is
that we have small, lightweight packages,
which are easy to share and reproduce, therefore.
We have a reproducible environment locked
into that container, after all.
That is the main asset,
the main selling point
of Docker containers, in the end.
Now, we also learned
that these containers are kind of stateless.
It's a term I didn't really use,
but it means the data which is written
in a container and that is possible,
containers can write data,
will be lost whenever a container is shut down.
With the exception of volumes, of course.
We can use volumes to kind of mirror
or copy certain folders in our container
to folders on our localhost machine.
And therefore the data
in those volumes will survive,
even if a container is shut down.
Now containers, as you learned,
are created with images.
The images are created with Dockerfiles
or pulled from Docker Hub,
but they are of course someone else created them
with a Dockerfile,
and they contain the code and the environment,
as described in the Dockerfile.
And then the container is just extra thin layer
on top of the image,
and we can run multiple containers
on one of the same image.
That's indeed the core idea
behind images, that they are shareable,
and then multiple containers can be created based on them.
Now, therefore, they act as blueprints
for containers,
as I said, they contain the code and environment.
They are read-only,
which means that the image itself does not run.
It does not write any code inside of it.
If you run a container based off an image,
and that container generates some data,
that data is not written into the image,
it's just written in that container read-write filesystem
in that thin layer on top of the image.
And therefore, the image will never change
and can easily be built and shared with others.
We create the image by defining these instructions,
and that in turn creates these different layers,
as it's called,
which basically ensures
that if only one instruction changes,
not everything needs to be executed again,
but instead these layers are cached
and can be reused.
And hence, building these images is efficient process
and can be very quick.
And then the container is just an extra thin layer
on top of the image,
which is created a new,
for every new container we run.
That, in a nutshell, is what Docker is about
and what containers are about.
Images and containers working together.