Symfony 5.0 on Nginx + PHP FPM under Docker [Part 2]

What will be told in this second part?

As I've mentioned on youtube video (, this article have 2 parts. In this, second part, I will show you docker image building process, Nginx config and docker-compose.yaml configuration to start docker image.

In previous part I have showed you my Dockerfile that is base to build docker image. Also I have prepared separate sh files for building and running docker. In my example that files does not contain to much code but in real project you may need do another things, like pushing image to Gitlab or another container repositories and run another things or commands after or before you run docker container, like database migrations, cache clearing or else...

In my I have command:
docker build --no-cache -f docker/Dockerfile -t birkof_blog .

Lets run it and see how building process runs:

Building Docker for Symfony 5.0 Framework

Building Docker for Symfony 5.0 Framework with Nginx and PHP7.4

Finishing commands running from Dockerfile during building Docker

Running commands from Dockerfile during building Docker container

After image is ready we can start the docker by running:
docker-compose -f docker/docker-compose.yaml up -d

I have added this code to my After running it we can check if everything is working opening http://localhost:8888. That exact address is defined in docker-compose.yaml which is configuration file and say how docker container should be composed and brought up.
The are many different abilities of configuration, for example mounting application and server logs from external folder - it will help while debugging and also it will reduce container size that.
Reduced container size makes it faster to start/stop or restart container. It is very important, specially when you're running on production.


Also verification if docker container is up can be made by running docker ps command in terminal. This command will show you active running docker images.

Checking running docker containers

So if you see in your browser next view, that you've done everything correct. If you have any questions - feel free to contact me. Also I have described another aspects of building docker container, few words were told also about nginx configuration on my YouTube video, if you're interested - subscribe and watch the video.

Checking running docker containers
Want to take a look on code on Gitlab?

No problem - you can go to my repo on Gitlab and check the code:

Also welcome to my YouTube channel, watch and SUBSCRIBE