https://github.com/chi-teck/docker-lamp
https://github.com/chi-teck/docker-lamp
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/chi-teck/docker-lamp
- Owner: Chi-teck
- Created: 2021-01-01T12:48:35.000Z (almost 5 years ago)
- Default Branch: PHP-8.2
- Last Pushed: 2022-12-12T05:58:10.000Z (almost 3 years ago)
- Last Synced: 2024-12-29T13:33:04.996Z (9 months ago)
- Language: Vim Script
- Size: 72.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Docker LAMP stack for web development
**The container is intended for local usage and should never be used in production environment.**## What is inside
* Apache|Nginx
* MariaDB
* PHP 8
* phpMyAdmin
* Xdebug
* Composer
* PHP-CS-Fixer
* MailHog
* Node.js, npm, Yarn
* SSH server## Creating the container
The container can be created in two ways. The first one (classic) is exposing container services through the explicit port mapping.
```bash
#!/usr/bin/env bashPROJECT_NAME=example
PROJECT_DIR=/var/docker/projects/$PROJECT_NAMEdocker create \
-h $PROJECT_NAME \
-p 80:80 \
-v $PROJECT_DIR/www:/var/www \
-v $PROJECT_DIR/mysql:/var/lib/mysql \
--name $PROJECT_NAME \
--env SERVER=apache \
--group-add sudo \
--group-add www-data \
attr/lamp
```
At this point the container can be started with the following command `docker start example`.
Having this done you can access web server index page by navigating to the following url: http://localhost.If you want to use Nginx instead of Appache set `SERVER=nginx` in the above command.
The second way requires you to create custom docker network.
```bash
#!/usr/bin/env bashdocker network create \
--subnet=172.28.0.0/16 \
--gateway=172.28.0.254 \
my-net
```
Now the container can be created as follows:
```bash
#!/usr/bin/env bashPROJECT_NAME=example
PROJECT_DIR=/var/docker/projects/$PROJECT_NAMEdocker create \
-h $PROJECT_NAME \
-v $PROJECT_DIR/www:/var/www \
-v $PROJECT_DIR/mysql:/var/lib/mysql \
--net my-net \
--ip 172.28.0.1 \
--name $PROJECT_NAME \
--env SERVER=apache \
--group-add sudo \
--group-add www-data \
attr/lamp
```
The IP address may be whatever you like but make sure it belongs the subnet you created before. It can be helpful to map the IP address to a hostname using _/etc/hosts_ file.
```
172.28.0.1 example.local
```
New containers can be attached to the same network or to a distinct one for better isolation.## Connecting to the container
It is recommended you connect to the container using **lamp** account.
```
docker exec -itu lamp:www-data example bash
```You may create an alias for less typing.
```
echo 'alias example="docker start example && docker exec -itu lamp example bash"' >> ~/.bashrc
```## Xdebug
Xdebug is disabled by default for performance reason. Run the following
command to enable on before debugging.
```
sudo xdebug on
```## Available ports
* 22 - SSH
* 80 - HTTP
* 443 - HTTPS
* 1025 - MailHog SMTP
* 3306 - MySQL
* 8025 - MailHog web UI
* 8088 - PhpMyAdmin## Access
* Host user name - lamp
* Host user password - 123
* MySQL root password - 123