Lass Updated: 2/9/2025
The docker-compose.yaml file
Please note I did not include a version tag – as this appears to have been deprecated; or is going to be deprecated.
services:
apache:
image: php:8.2-apache
container_name: lamp-apache
ports:
- "80:80"
depends_on:
- mysql
volumes:
- ./www:/var/www/html
mysql:
image: mysql
container_name: mysql-container
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: lamp_db
MYSQL_USER: user
MYSQL_PASSWORD: password
ports:
- "3306:3306"
volumes:
- ./mysql_data:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: lamp-phpmyadmin
ports:
- "8081:80"
depends_on:
- mysql
environment:
PMA_HOST: mysql
PMA_USER: root
PMA_PASSWORD: root
Quick Note: – which means I am reminding myself…. 🙂
This creates 3 intendent services.
Quick note:
to bring up: docker compose up -d // to bring it up in detached mode
root@nodey:~/x2# docker compose up -d
[+] Running 4/4
✔ Network x2_default Created 0.2s
✔ Container mysql-container Started 3.2s
✔ Container lamp-phpmyadmin Started 3.1s
✔ Container lamp-apache Started 2.9s
Note I was in the x2 directory when I issued docker compose up -d and it created a network form me named x2_default.
Doing a quick docker ps let’s you know if things are up and running.
root@nodey:~/x2# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
256c8ead359a phpmyadmin/phpmyadmin "/docker-entrypoint.…" 10 hours ago Up 10 hours 0.0.0.0:8081->80/tcp, :::8081->80/tcp lamp-phpmyadmin
4ff4193beef0 php:8.2-apache "docker-php-entrypoi…" 10 hours ago Up 10 hours 0.0.0.0:80->80/tcp, :::80->80/tcp lamp-apache
d96b6b3b5104 mysql "docker-entrypoint.s…" 10 hours ago Up 10 hours 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql-container
Note you may need to keep an eye on your docker logs
docker logs d96
2025-02-09 15:43:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.2.0-1.el9 started.
I wish this case was contrived… but it wasn’t. If I am reading this right the stars were NOT in alignment with me. I *think* mysql was trying to upgrade itself… and failed. Opps. I am fairly sure I did a few things like wait just a tad; wiped all the containers out on my system and tried again. I wasn’t exactly subtle.
2025-02-09T15:28:49.381008Z 1 [ERROR] [MY-014060] [Server] Invalid MySQL server upgrade: Cannot upgrade from 80100 to 90200. Upgrade to next major version is only allowed from the last LTS release, which version 80100 is not.
2025-02-09T15:28:49.381270Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2025-02-09T15:28:49.381290Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-02-09T15:28:50.226556Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 9.2.0) MySQL Community Server - GPL.
2025-02-09T15:28:50.226581Z 0 [System] [MY-015016] [Server] MySQL Server - end.
To connect using the mysql client
mysql -h 127.0.0.1 -P 3306 -u user -p
Remember right now we only have access to the lamp_db as user.
mysql> use lamp_db;
I have used this in other examples. I use it again to stay consistent.
CREATE TABLE assets (
AssetID int,
hostname varchar(255),
osfamily varchar(255),
ipaddress varchar(255),
tag varchar(255)
);
Inserting some random test data.
INSERT INTO assets (AssetID, hostname, osfamily, ipaddress, tag)
VALUES(1,'NY-0001', 'NT_WORKSTATION','172.16.15.2','');
Checking on the data we just put in.
mysql> select * from assets;
+---------+----------+----------------+-------------+------+
| AssetID | hostname | osfamily | ipaddress | tag |
+---------+----------+----------------+-------------+------+
| 1 | NY-0001 | NT_WORKSTATION | 172.16.15.2 | |
+---------+----------+----------------+-------------+------+
1 row in set (0.00 sec)