So let's comment this MySQL container in.
It shouldn't come as a surprise
that we also have an official MySQL image
which we can use.
And we are going to use step two,
well launch a database
or launch a container
that has a MySQL database in it.
It's very comparable to the MongoDB image
which we used earlier in the course.
So here,
I want to add an image
and the image which I want to use here
is MySQL image
and here I want to use version 5.7
so this tag of this image.
This will pull in this image
and inside of the image
when it is started as a container,
a MySQL database will be started.
Now this database
will later be accessed by our PHP code
which will live in this PHP container
or which will be handled
by SP PHP container
and since all these services are in the same network,
we will be able to talk to this database
without any issues
simply by using this container name.
So we don't need to configure anything
regarding the networks here,
but there is one other thing
which we do need to configure here,
and that is the environment.
We need to provide some environment variables,
which are used by this image,
to setup a database,
a user, a password and so on.
And we find the detailed description again,
on the Docker Hub page
for this MySQL image.
So here you can see which environment variables can be set,
and what they do.
Now there are a couple of variables I want to set here,
however, I will set them not in this compose file
but in the ".env file."
So again I will edit "env folder"
and in there myMySQL.env file.
Now here I want to add the MYSQL _DATABASE variable,
so this one here,
and set this to an initial database name
of a default initial database
which will be created when this container starts up.
Now I will set this to a homestead,
you can find this in the Laravel documentation.
I also will set a default user,
again that's just another
environment variable which we can use.
And I'll set to that to a HOMESTEAD as well,
again using some Laravel defaults here,
then add a MySQL PASSWORD
to add a password for this initial root user
then I will set this to secrete.
Add a MySQL ROOT PASSWORD
and also set this to secrete,
and yeah that should be it.
With that we can go back to docker compose
and add this env file option here,
under MySQL container
and then point at the env folder
and there add the mysql.env file.
To utilize the environment variables
specified in that file
in that container.
And that is it for our free application containers.
Now in order to test whether everything works,
or if we made some mistake
we need a Laravel application,
and we will actually create that
with this composer tool.
So lets works on this composer container next.