LEMP Base Image: Apache2.4 + MySQL 5.7 + PHP7
483
LAMP in one container.
The master branch is linked to latest tag. But ironically, latest tag is linked to 16.04 tag for users who depends on appkr/lamp-base:latest.
| tag | Ubuntu | PHP | MySQL |
|---|---|---|---|
appkr/lamp-base:16.04 | 16.04 | 7.0 | 5.7 |
appkr/lamp-base:18.04 | 18.04 | 7.2 | 5.7 |
To download the already built image from docker hub and run it
~ $ docker run -d \
--name lamp1804 \
-v `pwd`/html:/var/www/html \
-v `pwd`/data:/var/lib/mysql \
-p 80:80 \
-p 3306:3306 \
-p 9001:9001 \
appkr/lamp-base:18.04
http://localhost to open a index page in document root of apache2.$ docker exec -it lamp1804 mysqlhttp://localhost:9001 to open the supervisor dashboard (Default account: homestead/secret).To build your own image:
~/ $ git clone [email protected]:appkr/lamp-base.git
~/ $ cd lamp-base
~/lamp-base(master) $ git checkout 18.04
~/lamp-base(18.04) $ docker build --tag mylamp:18.04 .
To run your own build:
~/lamp-base(18.04) $ docker run -d \
--name mylamp1804 \
-v `pwd`/html:/var/www/html \
-v `pwd`/data:/var/lib/mysql \
-p 80:80 \
-p 3306:3306 \
-p 9001:9001 \
mylamp:18.04
While building the Dockerfile, most of the errors were aroused from MySQL.
The first thing you have to look into is the logs. MySQL log lives in /var/log/mysql/error.log
"No directory, logging in with HOME=/" This happens when mysql user's home directory is not designated. Run usermod -d /var/lib/mysql/ mysql in the docker machine.
"Fatal error: Can't open and lock privileges table: Table 'mysql.user' does'nt exists" This happens when there is not mysql.user table. Stop the running container, remove all the content of local mounted volume for /var/lib/mysql(e.g. data), and then restart the container.
If MySQL root@% user was not correctly created:
~/any $ docker exec -it <container_name_or_hash> \
mysql -v -e "CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;"
If MySql socket was not correctly created("spawn error" or "socket ..."):
~/any $ docker exec -it lamp bash /refresh_mysql_pid.sh
In most cases, starting from scratch is much easier. To do that run the following commands and re-iterate from the beginning:
# Clean up the MySql data directory
~/lamp-base $ ls -d data/* | grep -v .gitignore | xargs rm -rf
# Stop running container and remove it
~/any $ docker container stop lamp1804 && docker container rm lamp1804
# Remove image
~/any $ docker image --force appkr/lamp-base:18.04
Content type
Image
Digest
Size
171.4 MB
Last updated
over 7 years ago
docker pull appkr/lamp-base