A CakePHP Docker Container which installs a fresh, fully configured and operational version of CakePHP 3.6. It comes with two pre-configured databases, for both production and testing environments and the app runs on PHP 7.0 up to 7.3, Apache 2.4 (or Nginx 1.14) and MariaDB 10.1 (read the MariaDB versus MySQL note below on why MariaDB was chosen over MySQL).
- Installation
- Supported Tags and respective
Dockerfile
links - Modifying CakePHP Settings
- MariaDB versus MySQL
- Accessing the Databases
- What is CakePHP?
- Quick reference
Installation is dead-easy. Just run the following command and then visit your browser (e.g. http://192.168.99.1) to see your newly configured CakePHP website.
docker run -p 80:80 justinhartman/cakephp3.5-php7-mysql-apache2:latest
Below are tags to various PHP versions running either Apache
or Nginx
which
come pre-installed in all the containers. Pick the version of PHP and web-server
of your choosing, based on the tags below, when installing or running a
container.
You have two options when installing PHP with Apache 2.4. These are the built in
Apache 2 PHP module (mod_php
) or the stand-alone FastCGI PHP server
(php-fpm
). You can install either mod_php
or php-fpm
by selecting one of
the tags below.
apache-php-7.3.0
,apache-php-7.3
,apache-7.3
(apache/php/7.3/Dockerfile)apache-php-7.2.9
,apache-php-7.2
,apache-7.2
,latest
(apache/php/7.2/Dockerfile)apache-php-7.1.20
,apache-php-7.1
,apache-7.1
(apache/php/7.1/Dockerfile)apache-php-7.0.31
,apache-php-7.0
,apache-7.0
(apache/php/7.0/Dockerfile)
apache-fpm-7.3.0
,apache-fpm-7.3
(apache/php-fpm/7.3/Dockerfile)apache-fpm-7.2.9
,apache-fpm-7.2
(apache/php-fpm/7.2/Dockerfile)apache-fpm-7.1.20
,apache-fpm-7.1
(apache/php-fpm/7.1/Dockerfile)apache-fpm-7.0.31
,apache-fpm-7.0
(apache/php-fpm/7.0/Dockerfile)
The mod_php
and php-fpm
Docker containers also come with the following
additional software installed:
- CakePHP 3.6.11
- Apache 2.4.34
- MariaDB 10.1.35
By default the Nginx Docker containers all run on the stand-alone FastCGI PHP
server (php-fpm
) and are pre-configured with this deployment of PHP.
nginx-fpm-7.3.0
,nginx-fpm-7.3
,nginx-7.3
(php/nginx/7.3/Dockerfile)nginx-fpm-7.2.9
,nginx-fpm-7.2
,nginx-7.2
(php/nginx/7.2/Dockerfile)nginx-fpm-7.1.20
,nginx-fpm-7.1
,nginx-7.1
(php/nginx/7.1/Dockerfile)nginx-fpm-7.0.31
,nginx-fpm-7.0
,nginx-7.0
(php/nginx/7.0/Dockerfile)
The nginx
containers also come with the following additional software
installed:
- CakePHP 3.6.11
- Nginx 1.14.0
- MariaDB 10.1.35
There is dotenv support which has been made available in your
/config/bootstrap.php
file. You can access and modify any settings you'd like
to make by editing /config/.env
. Do not make changes to either
/config/app.php
or /config/app.default.php
as it is better to work off the
.env
file for any configuration changes.
The .env
file has configuration options for:
- General app settings
- Cache control
- Email transport
- Database connection
- Logging options
- Session and Error level handling
MariaDB 10.1 is installed due to a bug with MySQL 5.7 that prevents it
installing when building on Docker Hub. Ironically, if you build the image on
your machine MySQL 5.7 builds fine so the issue, for whatever reason, only
exists on Docker Hub. If you need MySQL 5.7 you could change the
mariadb-server
option to mysql-server
by editing the Dockerfile
and
building the image yourself.
The containers come with MariaDB pre-installed. During the Docker creation, two databases are installed for both production and any unit tests you need to run.
Database: cakephp_live
Username: cakephp_live_user
Password: b5uF95fstJmhABD4is
Connection: DATABASE_URL
exists in your /config/.env
file with the full
connection string to the production database.
Database: cakephp_test
Username: cakephp_test_user
Password: 4hiEKuzgFr54fyPVQJ
Connection: DATABASE_TEST_URL
exists in your /config/.env
file with the full
connection string to the testing database.
If you'd like to change the password for the two default MySQL user accounts
then run the following commands in MySQL - replace $PASSWORD
with your new
password for the account.
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'cakephp_live_user'@'localhost' IDENTIFIED BY '$PASSWORD';
mysql> ALTER USER 'cakephp_test_user'@'localhost' IDENTIFIED BY '$PASSWORD';
The MySQL root password has not been set in the Docker container.
Please make sure to change this and set a password for your root
MySQL
account as it is not secure if left as is. You can follow the same method above
to set a root
password or you could run $ mysql_secure_installation
in a
terminal window in the Container Image which would completely secure your
MySQL installation.
CakePHP is an open source web application framework. It follows the Model-View-Controller (MVC) approach and is written in PHP, modelled after the concepts of Ruby on Rails, and distributed under the MIT License.
- Where to file issues:
@justinhartman/docker-cakephp3.6-php7-mysql-apache2/issues - Maintained by:
Justin Hartman - Supported Docker versions:
the latest release (down to 1.6 on a best-effort basis)