You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 29, 2021. It is now read-only.
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.
3
3
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!**
-[`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.
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).
96
7
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.
98
8
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.
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
-
```
115
12
13
+
## Usage
116
14
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
119
16
120
-
The below examples assume the following project layout and that you are running the commands from the 'project root'.
121
17
```
122
18
/ (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)
133
21
```
134
22
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
137
24
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
141
25
```
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.
docker run -p "80:80" -v ${PWD}/app:/app -v ${PWD}/mysql:/var/lib/mysql jakejarvis/lamp-php5:latest
147
27
```
148
28
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)
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/"
206
45
```
46
+
FROM jakejarvis/lamp-php5:latest
207
47
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
210
49
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"]
215
51
```
216
52
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
236
54
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.
237
56
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.
240
58
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.
247
60
248
61
249
62
## License
@@ -257,12 +70,8 @@ Docker-LAMP is licensed under the [Apache 2.0 License][info-license].
0 commit comments