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?
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:
- mysql ( mysql:latest )
- php w. apache ( php:7-apache-buster )
- 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.
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.
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:
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)