Dockerize CRM php/mysql/apache etc

Hi again.

When building an application like this, instead of running 3x "docker run … ", its impossible to keep track of, instead you would use something like docker-compose, which is a recipe of a service.

A simple mysql/apache+php docker-compose would look like this:

version: '3'
services:
  php:
    ports:
      - '80:80'
    container_name: my-apache-php-app
    volumes:
      - '/my/path/to/www:/var/www/html'
    image: 'php:7-apache-buster'

  mariadb:
    container_name: some-mariadb
    environment:
      - MARIADB_USER=example-user
      - MARIADB_PASSWORD=my_cool_secret
      - MARIADB_ROOT_PASSWORD=my-secret-pw
    volumes:
      - '/my/own/datadir:/var/lib/mysql'
    image: 'mariadb:latest'

if you put this into a file: docker-compose.yml, and run: docker-compose up -d

You will see that it downloads the images, creates a shared network for these 2 containers, and starts them.
(note the /my/path/to/www and /my/own/datadir)

now, you should be able to see your webpage on port 80, and if you want to contact the mysql from the php container, you simply type in “mariadb” as the hostname (since its the service name)