Skip to content
This repository was archived by the owner on Mar 29, 2021. It is now read-only.

Commit 17cf8a5

Browse files
authored
Update README.md
1 parent 126e03b commit 17cf8a5

File tree

1 file changed

+30
-221
lines changed

1 file changed

+30
-221
lines changed

README.md

Lines changed: 30 additions & 221 deletions
Original file line numberDiff line numberDiff line change
@@ -1,249 +1,62 @@
11
# ![Docker-LAMP][logo]
2-
Docker-LAMP is a set of docker images that include the Phusion baseimage along with a LAMP stack ([Apache][apache], [MySQL][mysql] and [PHP][php]) all in one handy package.
2+
Docker-LAMP-PHP5 is a Docker image that includes the Phusion base along with a LAMP stack ([Apache 2.4.7][apache], [MySQL 5.7][mysql] and [PHP 5.6][php]) on Ubuntu 16.04 Xenial, all in one handy container. [phpMyAdmin][phpmyadmin] is also bundled.
33

4-
**This image is only intended for legacy PHP 5.6 applications, which is [end-of-life](https://www.php.net/supported-versions.php) as of January 2019. Use at your own risk, preferably not in production and/or public-facing environments!**
4+
**This image is only intended for legacy PHP 5.6 applications, which is [end-of-life](https://www.php.net/supported-versions.php) as of January 2019. Use at your own risk, preferably *not* in production and/or public-facing environments!**
55

6-
<!-- [![Build Status][shield-build-status]][info-build-status] -->
7-
[![Docker Hub][shield-docker-hub]][info-docker-hub]
8-
[![License][shield-license]][info-license]
9-
10-
### Contents
11-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
12-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
13-
14-
15-
- [Introduction](#introduction)
16-
- [Image Versions](#image-versions)
17-
- [Using the image](#using-the-image)
18-
- [On the command line](#on-the-command-line)
19-
- [With a Dockerfile](#with-a-dockerfile)
20-
- [MySQL Databases](#mysql-databases)
21-
- [Creating a database](#creating-a-database)
22-
- [PHPMyAdmin](#phpmyadmin)
23-
- [Command Line](#command-line)
24-
- [Adding your own content](#adding-your-own-content)
25-
- [Adding your app](#adding-your-app)
26-
- [Persisting your MySQL](#persisting-your-mysql)
27-
- [Doing both](#doing-both)
28-
- [`.bash_profile` alias examples](#bash_profile-alias-examples)
29-
- [Example usage](#example-usage)
30-
- [Developing the image](#developing-the-image)
31-
- [Building and running](#building-and-running)
32-
- [Testing](#testing)
33-
- [One-line testing command](#one-line-testing-command)
34-
- [`docker-compose -f docker-compose.test.yml -p ci build;`](#docker-compose--f-docker-composetestyml--p-ci-build)
35-
- [`docker-compose -f docker-compose.test.yml -p ci up -d;`](#docker-compose--f-docker-composetestyml--p-ci-up--d)
36-
- [`docker logs -f ci_sut_1;`](#docker-logs--f-ci_sut_1)
37-
- [`echo "Exited with status code: $(docker wait ci_sut_1)"`](#echo-exited-with-status-code-docker-wait-ci_sut_1)
38-
- [Inspiration](#inspiration)
39-
- [Contributing](#contributing)
40-
- [License](#license)
41-
42-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
43-
44-
## Introduction
45-
As a developer, part of my day to day role is to build LAMP applications. I searched in vein for an image that had everything I wanted, up-to-date packages, a simple interface, good documentation and active support.
46-
47-
To complicate things even further I needed an image, or actually two, that would run my applications on both 14.04 and 16.04. Having two entirely separate workflows didn't make any sense to me, and Docker-LAMP was born.
48-
49-
Designed to be a single interface that just 'gets out of your way', and works on 14.04 and 16.04 with php 5 and 7. You can move between all 4 images without changing how you work with Docker.
50-
51-
## Image Versions
52-
> **NOTE:** [PHP 5.6 is end of life][end-of-life], so the PHP 5 images `mattrayner/lamp:latest-1404-php5` and `mattrayner/lamp:latest-1604-php5` will not receive any updates. Although these images will stay on Docker Hub, we **strongly** recommend updating you applications to PHP7.
53-
54-
> **NOTE**: The 14.04 variant of this image is no longer being actively supported for updated
55-
56-
There are 4 main 'versions' of the docker image. The table below shows the different tags you can use, along with the PHP, MySQL and Apache versions that come with it.
57-
58-
Component | `latest-1404` | `latest-1604` | `latest-1804`
59-
---|---|---|---
60-
[Apache][apache] | `2.4.7` | `2.4.18` | `2.4.29`
61-
[MySQL][mysql] | `5.5.62` | `5.7.26` | `5.7.26`
62-
[PHP][php] | `7.3.3` | `7.3.6` | `7.3.6`
63-
[phpMyAdmin][phpmyadmin] | `4.8.5` | `4.9.0.1` | `4.9.0.1`
64-
65-
66-
## Using the image
67-
### On the command line
68-
This is the quickest way
69-
```bash
70-
# Launch a 16.04 (php5) based image
71-
docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-1604
72-
73-
# Launch a 14.04 (php5) based image
74-
docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-1404
75-
76-
# Launch a 16.04 (php7) based image
77-
docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-1604-php7
78-
79-
# Launch a 14.04 (php7) based image
80-
docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-1404-php7
81-
```
82-
83-
### With a Dockerfile
84-
```docker
85-
FROM mattrayner/lamp:latest-1604
86-
87-
# Your custom commands
88-
89-
CMD ["/run.sh"]
90-
```
91-
92-
### MySQL Databases
93-
By default, the image comes with a `root` MySQL account that has no password. This account is only available locally, i.e. within your application. It is not available from outside your docker image or through phpMyAdmin.
94-
95-
When you first run the image you'll see a message showing your `admin` user's password. This user can be used locally and externally, either by connecting to your MySQL port (default 3306) and using a tool like MySQL Workbench or Sequel Pro, or through phpMyAdmin.
6+
Based off an old version of [mattrayner/docker-lamp](https://github.com/mattrayner/docker-lamp).
967

97-
If you need this login later, you can run `docker logs CONTAINER_ID` and you should see it at the top of the log.
988

99-
#### Creating a database
100-
So your application needs a database - you have two options...
101-
102-
1. PHPMyAdmin
103-
2. Command line
104-
105-
##### PHPMyAdmin
106-
Docker-LAMP comes pre-installed with phpMyAdmin available from `http://DOCKER_ADDRESS/phpmyadmin`.
107-
108-
**NOTE:** you cannot use the `root` user with PHPMyAdmin. We recommend logging in with the admin user mentioned in the introduction to this section.
9+
[![Docker Hub][shield-docker-hub]][info-docker-hub]
10+
[![License][shield-license]][info-license]
10911

110-
##### Command Line
111-
First, get the ID of your running container with `docker ps`, then run the below command replacing `CONTAINER_ID` and `DATABASE_NAME` with your required values:
112-
```bash
113-
docker exec CONTAINER_ID mysql -uroot -e "create database DATABASE_NAME"
114-
```
11512

13+
## Usage
11614

117-
## Adding your own content
118-
The 'easiest' way to add your own content to the lamp image is using Docker volumes. This will effectively 'sync' a particular folder on your machine with that on the docker container.
15+
### Directory structure
11916

120-
The below examples assume the following project layout and that you are running the commands from the 'project root'.
12117
```
12218
/ (project root)
123-
/app/ (your PHP files live here)
124-
/mysql/ (docker will create this and store your MySQL data here)
125-
```
126-
127-
In english, your project should contain a folder called `app` containing all of your app's code. That's pretty much it.
128-
129-
### Adding your app
130-
The below command will run the docker image `mattrayner/lamp` interactively, exposing port `80` on the host machine with port `80` on the docker container. It will then create a volume linking the `app/` directory within your project to the `/app` directory on the container. This is where Apache is expecting your PHP to live.
131-
```bash
132-
docker run -i -t -p "80:80" -v ${PWD}/app:/app mattrayner/lamp
19+
/app/ (your PHP files aka the web root)
20+
/mysql/ (Docker will create this and store your MySQL data here)
13321
```
13422

135-
### Persisting your MySQL
136-
The below command will run the docker image `mattrayner/lamp`, creating a `mysql/` folder within your project. This folder will be linked to `/var/lib/mysql` where all of the MySQL files from container lives. You will now be able to stop/start the container and keep your database changes.
23+
### Starting from command line
13724

138-
You may also add `-p 3306:3306` after `-p 80:80` to expose the mysql sockets on your host machine. This will allow you to connect an external application such as SequelPro or MySQL Workbench.
139-
```bash
140-
docker run -i -t -p "80:80" -v ${PWD}/mysql:/var/lib/mysql mattrayner/lamp
14125
```
142-
143-
### Doing both
144-
The below command is our 'recommended' solution. It both adds your own PHP and persists database files. We have created a more advanced alias in our `.bash_profile` files to enable the short commands `ldi` and `launchdocker`. See the next section for an example.
145-
```bash
146-
docker run -i -t -p "80:80" -v ${PWD}/app:/app -v ${PWD}/mysql:/var/lib/mysql mattrayner/lamp:latest
26+
docker run -p "80:80" -v ${PWD}/app:/app -v ${PWD}/mysql:/var/lib/mysql jakejarvis/lamp-php5:latest
14727
```
14828

149-
#### `.bash_profile` alias examples
150-
The below example can be added to your `~/.bash_profile` file to add the alias commands `ldi` and `launchdocker`. By default it will launch the 16.04 image - if you need the 14.04 image, simply change the `docker run` command to use `mattrayner/lamp:latest-1404` instead of `mattrayner/lamp:latest`.
151-
```bash
152-
# A helper function to launch docker container using mattrayner/lamp with overrideable parameters
153-
#
154-
# $1 - Apache Port (optional)
155-
# $2 - MySQL Port (optional - no value will cause MySQL not to be mapped)
156-
function launchdockerwithparams {
157-
APACHE_PORT=80
158-
MYSQL_PORT_COMMAND=""
159-
160-
if ! [[ -z "$1" ]]; then
161-
APACHE_PORT=$1
162-
fi
163-
164-
if ! [[ -z "$2" ]]; then
165-
MYSQL_PORT_COMMAND="-p \"$2:3306\""
166-
fi
29+
### Starting with Docker Compose
16730

168-
docker run -i -t -p "$APACHE_PORT:80" $MYSQL_PORT_COMMAND -v ${PWD}/app:/app -v ${PWD}/mysql:/var/lib/mysql mattrayner/lamp:latest
169-
}
170-
alias launchdocker='launchdockerwithparams $1 $2'
171-
alias ldi='launchdockerwithparams $1 $2'
17231
```
173-
174-
##### Example usage
175-
```bash
176-
# Launch docker and map port 80 for apache
177-
ldi
178-
179-
# Launch docker and map port 8080 for apache
180-
ldi 8080
181-
182-
# Launch docker and map port 3000 for apache along with 3306 for MySQL
183-
ldi 3000 3306
32+
version: "3"
33+
services:
34+
lamp:
35+
image: jakejarvis/lamp-php5:latest
36+
ports:
37+
- "80:80"
38+
volumes:
39+
- "./app:/app"
40+
- "./mysql:/var/lib/mysql"
18441
```
18542

43+
### Starting from a Dockerfile
18644

187-
## Developing the image
188-
### Building and running
189-
```bash
190-
# Clone the project from Github
191-
git clone https://github.com/mattrayner/docker-lamp.git
192-
cd docker-lamp
193-
194-
# Build both the 16.04 image and the 14.04 php5 images
195-
docker build -t=mattrayner/lamp:latest -f ./1604/Dockerfile-php5 .
196-
docker build -t=mattrayner/lamp:latest-1404 -f ./1404/Dockerfile-php5 .
197-
198-
# Run the 14.04 image as a container
199-
docker run -p "3000:80" mattrayner/lamp:latest-1404 -d
200-
201-
# Sleep to allow the container to boot
202-
sleep 5
203-
204-
# Curl out the contents of our new container
205-
curl "http://$(docker-machine ip):3000/"
20645
```
46+
FROM jakejarvis/lamp-php5:latest
20747
208-
### Testing
209-
We use `docker-compose` to setup, build and run our testing environment. It allows us to offload a large amount of the testing overhead to Docker, and to ensure that we always test our image in a consistent way thats not affected by the host machine.
48+
# Your custom commands
21049
211-
### One-line testing command
212-
We've developed a single-line test command you can run on your machine within the `docker-lamp` directory. This will test any changes that may have been made, as well as comparing installed versions of Apache, MySQL, PHP and phpMyAdmin against those expected.
213-
```bash
214-
docker-compose -f docker-compose.test.yml -p ci build; docker-compose -f docker-compose.test.yml -p ci up -d; docker logs -f ci_sut_1; echo "Exited with status code: $(docker wait ci_sut_1)";
50+
CMD ["/run.sh"]
21551
```
21652

217-
So what does this command do?
218-
219-
#### `docker-compose -f docker-compose.test.yml -p ci build;`
220-
First, build that latest version of our docker-compose images.
221-
222-
#### `docker-compose -f docker-compose.test.yml -p ci up -d;`
223-
Launch our docker containers (`web1604`, `web1404` and `sut` or *system under tests*) in daemon mode.
224-
225-
#### `docker logs -f ci_sut_1;`
226-
Display all of the logging output from the `sut` container (extremely useful for debugging)
227-
228-
#### `echo "Exited with status code: $(docker wait ci_sut_1)"`
229-
Report back the status code that the `sut` container ended with.
230-
231-
232-
## Inspiration
233-
This image was originally based on [dgraziotin/lamp][dgraziotin-lamp], with a few changes to make it compatible with the Concrete5 CMS.
234-
235-
I also changed the setup to create ubuntu (well, baseimage, but you get what I'm saying) 14.04 and 16.04 images so that this project could be as useful as possible to as many people as possible.
53+
### MySQL Databases
23654

55+
When you first run the image, you'll see a message showing your `admin` user's password. This is the user you should use in your application. If you need this login later, you can run `docker logs CONTAINER_ID` and you should see it at the top of the log.
23756

238-
## Contributing
239-
If you wish to submit a bug fix or feature, you can create a pull request and it will be merged pending a code review.
57+
You can access [phpMyAdmin][phpmyadmin] at `/phpmyadmin` with the `admin` username and password.
24058

241-
1. Clone/fork it
242-
2. Create your feature branch (git checkout -b my-new-feature)
243-
3. Commit your changes (git commit -am 'Add some feature')
244-
4. Test your changes using the steps in [Testing](#testing)
245-
5. Push to the branch (git push origin my-new-feature)
246-
6. Create a new Pull Request
59+
By default, the image comes with a `root` MySQL account that has no password. This account is only available locally, i.e. within your application. It is not available from outside your Docker image or through phpMyAdmin.
24760

24861

24962
## License
@@ -257,12 +70,8 @@ Docker-LAMP is licensed under the [Apache 2.0 License][info-license].
25770
[php]: http://php.net/
25871
[phpmyadmin]: https://www.phpmyadmin.net/
25972

260-
[info-build-status]: https://circleci.com/gh/mattrayner/docker-lamp
26173
[info-docker-hub]: https://hub.docker.com/r/jakejarvis/lamp-php5
262-
[info-license]: LICENSE
74+
[info-license]: LICENSE.md
26375

264-
[shield-build-status]: https://img.shields.io/circleci/project/mattrayner/docker-lamp.svg
26576
[shield-docker-hub]: https://img.shields.io/docker/build/jakejarvis/lamp-php5.svg
26677
[shield-license]: https://img.shields.io/badge/license-Apache%202.0-blue.svg
267-
268-
[dgraziotin-lamp]: https://github.com/dgraziotin/osx-docker-lamp

0 commit comments

Comments
 (0)