There are many ways that you can use Phalcon with Docker.
With Phalcon-compose you can create an isolated environment with docker, that will allow you to use Phalcon without any additional installations. Note that using Phalcon Compose, requires Docker Engine >= 1.10.0 and Docker Compose >= 1.6.2
Phalcon Compose offers the following services by default:
Phalcon Compose is very easy to use. Assume that you need to create an application that will be located in:
/home/website. We will now need to run the following command for our container application can be created:
The above command will download the skeleton of the docker environment.
composer create-project sergeyklay/phalcon-compose --prefer-dist /home/website
You will need to create a new file called
/home/website. A sample file has been provided called
Adjust the variables in that file to suit your needs. The most important variable is the
cd /home/website cp variables.env.example variables.env nano variables.env
WEB_ALIAS_DOMAIN. Change the name to something you will be able to use. In our case we just leave the default called
Open your hosts file (
/etc/hosts) and enter a new line like this:
You might want to edit the
docker-compose.yml file and remove services that you will not be using. Phalcon Compose offers a lot of services as mentioned above, so your application might not need some of them. Removing the relevant services from the
docker-compose.yml file will reduce memory usage of your environment.
You can now build the environment.
Containers will be downloaded as needed and set up on your environment.
You can now launch the environment:
cd /home/website docker-compose up -d
http://phalcon.local in your browser and you will see your environment is set up. You can now develop your application in the app folder.
To shut down the environment when is no longer needed you can issue the following command:
Additional information can be found at: https://phalcon.link/compose
cd /home/website docker-compose down