LAMP

This project gives a LAMP (Linux Apache MySQL PHP) Dockerfile ready to load the PHP custom configuration.

The internal servers listen to ports 80 and 3306

PHP server reads what is in the docker "/app" directory. So either you copy the whole application code in that directory or you bind the /app docker directory to the directory where you develop/store the application with the "-v" docker option.

Getting started

Build own image

Go to where you copied the Dockerfile:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$ cd /path/to/my/lamp/dockerfile
$ [sudo] docker build -t my-lamp-app .

Sending build context to Docker daemon  19.97kB
Step 1/7 : FROM tutum/lamp:latest
 ---> 3d49e175ec00
Step 2/7 : LABEL atom="LAMP"
 ---> Running in ad7c57408c42
Removing intermediate container ad7c57408c42
 ---> 9459c1eddc49
Step 3/7 : LABEL REPO="https://gitlab.forge.orange-labs.fr/lucy/toolbox/LAMP"
 ---> Running in 0d37dde500a1
Removing intermediate container 0d37dde500a1
 ---> 77f0b8019e25
Step 4/7 : RUN rm -fr /app
 ---> Running in 00974a27d6f1
Removing intermediate container 00974a27d6f1
 ---> 01574a0e85ae
Step 5/7 : VOLUME ["/app"]
 ---> Running in beaf1827c339
Removing intermediate container beaf1827c339
 ---> e6aceac49a47
Step 6/7 : EXPOSE 80 3306
 ---> Running in 225972eae084
Removing intermediate container 225972eae084
 ---> 5965f5e3d46c
Step 7/7 : CMD ["/run.sh"]
 ---> Running in 33a8622a6025
Removing intermediate container 33a8622a6025
 ---> 370ace57d813
Successfully built 370ace57d813
Successfully tagged my-lamp-app:latest

Run Docker image

Running it then should be as simple as:

1
2
3
$ [sudo] docker run -d -p 8080:80 -p 3306:3306 -v /my/awesome/php/app:/app my-lamp-app

docker id number (i.e.: 95c3b40b59ab37fd6a368f0a9df2e6c77a71a0d1ba3d3192eeba92f8fee31927)

Parameters:

1
2
3
/my/awesome/php/app: path in the host to the php application. The PHP server will look for "index.php".

/app : path in the docker where the php server will look for the php application.

Binding ports

  • Webserver:
1
2
- host port: 8080
- docker server port: 80
  • MYSQL
1
port: 3306

Check PHP application

In the web browser:

1
http://localhost:8080

Or

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
curl http://localhost:8080

<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
(...)
</head>
<body>
(...)
</body>
</html>