Sign inSign up

appkr/lamp-base

By appkr

Updated about 7 years ago

LEMP Base Image: Apache2.4 + MySQL 5.7 + PHP7

Image
0

483

appkr/lamp-base repository overview

Travis build Docker build Docker downloads

LAMP Base Docker Image

1. What Is This?

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.

tagUbuntuPHPMySQL
appkr/lamp-base:16.0416.047.05.7
appkr/lamp-base:18.0418.047.25.7

2. Quick Start

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

3. Test

  • http://localhost to open a index page in document root of apache2.
  • $ docker exec -it lamp1804 mysql
  • http://localhost:9001 to open the supervisor dashboard (Default account: homestead/secret).

4. Your Own Build

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

5. Troubleshooting

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
    

Tag summary

Content type

Image

Digest

Size

171.4 MB

Last updated

over 7 years ago

docker pull appkr/lamp-base