Create your first PHP/MySQL application in docker

Using command line based tools like docker build and docker run could be tedious in real-world scenarios where you have to run multiple containers.You can consider Compose a batch file that contains a set of instructions, commands to perform operations.Just like you create a Dockerfile to define how your image look like, in docker-compose.yml file you can the mention the image(s) you want to use as well as the parameters of run and docker build commands..Without further ado, let’s start creating our docker-compose.yml file.You can check the docker compose version by running the command docker-compose –version on command line..Mine output is docker-compose version 1.23.1, build b02f1306.Let’s create a simple docker compose file that will be doing the same thing that we did in the previous post.version: '2'services:website:container_name: php72image: tut:php_imgbuild:context: ./volumes:- /Development/PetProjects/DockerPHPTutorial/src:/var/www/html/ports:- 8000:80The very first line is about the version of docker compose itself..Right now version 3 is available but since I have an old installation so I stick with it..The services section will contain the list of all the tools/services you are intended to run..Since I will be making websites in PHP so I just named it as website..You may dedicate it your friend or sweetheart, doesn’t make any difference..Just do remember that this name will be used to communicate with other containers..Under the website section I set container_name which is obviously for setting the name of the container..The image section is timilar to set the tag in docker run command..Under the build you will find context section..It is actually to look for the Dockerfile.. More details

Leave a Reply