Dockerize CRM php/mysql/apache etc

Hi I am new to this community and I am trying to dockerize a management app. This app is developed in php/mysql and is currently running on apache2.
The management app needs some things such as curl, ssh, ssl (let’s encrypt)…
In your opinion is what image should I start from? A linux distribution, for example an image of UBUNTU SERVER?

thanks

Hi :slight_smile:

When using docker, you want to split it up as much as possible, so 1 image containing all services, mysql, php, ssl, is generally a no-go.

Instead you would have a container that:

  1. mysql ( mysql:latest )
  2. php w. apache ( php:7-apache-buster )
  3. a proxy in front, that will SSL terminate your application ( traefik(?) )

If its a basic webserver, then there is no reason to build your own image, i can see that you list ssh/curl also, but that can be added to the php:7-apache-buster image if needed.

1 Like

Thank very much Martin for this valuable information!

Do you have any example I can see to learning about?
I would like to fully understand how to create these containers using one command and especially how they talk to each other.

Thanks!

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)