Docker-LAMP is a set of docker images that include the phusion baseimage (14.04, 16.04 and 18.04 varieties), along with a LAMP stack (Apache, MySQL and PHP) all in one handy package.
With Ubuntu 18.04 amd 16.04 images on the
latest-1804
and latest-1604
tags, Docker-LAMP is flexible enough to use with all of your LAMP projects.Contents
Why Nginx over Apache for Docker? (self.docker) submitted 2 years ago by Valien. Fairly new to Docker and pretty much all our production sites are running under Apache. I've used Nginx for 1 production site and for testing. I like it and it works well, but is there a compelling reason to utilize Nginx over Apache in the container world? Read more about troubleshooting Apache SSL Certificate errors. Troubleshooting Apache SSL Certificate Errors. There are a few different SSL-related errors in Apache that can cause the following issues: SSL errors are reported in the log file causing Apache to not start.
- Using the image
- MySQL Databases
- Creating a database
- MySQL Databases
- Adding your own content
- Doing both
.bash_profile
alias examples
- Doing both
- Developing the image
- One-line testing command
Introduction
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.
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.
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.
Image Versions
NOTE:PHP 5.6 is 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.NOTE: The 14.04 variant of this image is no longer being actively supported for updated
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.
Component | latest-1404 | latest-1604 | latest-1804 |
---|---|---|---|
Apache | 2.4.7 | 2.4.18 | 2.4.29 |
MySQL | 5.5.62 | 5.7.26 | 5.7.26 |
PHP | 7.3.3 | 7.3.6 | 7.3.6 |
phpMyAdmin | 4.8.5 | 4.9.0.1 | 4.9.0.1 |
Using the image
On the command line
This is the quickest way
With a Dockerfile
MySQL Databases
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.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.If you need this login later, you can run
docker logs CONTAINER_ID
and you should see it at the top of the log.Creating a database
So your application needs a database - you have two options...
- PHPMyAdmin
- Command line
PHPMyAdmin
Docker-LAMP comes pre-installed with phpMyAdmin available from
http://DOCKER_ADDRESS/phpmyadmin
.NOTE: you cannot use the
root
user with PHPMyAdmin. We recommend logging in with the admin user mentioned in the introduction to this section.Command Line
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:Adding your own content
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.
The below examples assume the following project layout and that you are running the commands from the 'project root'.
In english, your project should contain a folder called
app
containing all of your app's code. That's pretty much it.Adding your app
The below command will run the docker image
mattrayner/lamp:latest
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.Persisting your MySQL
The below command will run the docker image
mattrayner/lamp:latest
, 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.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.Doing both
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..bash_profile
alias examples
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
.Example usage
Developing the image
Building and running
Testing
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.One-line testing command
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.So what does this command do?
docker-compose -f docker-compose.test.yml -p ci build;
First, build that latest version of our docker-compose images.
docker-compose -f docker-compose.test.yml -p ci up -d;
Launch our docker containers (
web1804
, web1604
, web1404
and sut
or system under tests) in daemon mode.docker logs -f ci_sut_1;
Display all of the logging output from the
sut
container (extremely useful for debugging)echo 'Exited with status code: $(docker wait ci_sut_1)'
Report back the status code that the
sut
container ended with.Inspiration
This image was originally based on dgraziotin/lamp, with a few changes to make it compatible with the Concrete5 CMS.
I also changed the setup to create ubuntu (well, baseimage, but you get what I'm saying) images so that this project could be as useful as possible to as many people as possible.
Contributing
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.
- Clone/fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Test your changes using the steps in Testing
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
License
Docker-LAMP is licensed under the Apache 2.0 License.
I am doing a tutorial on Mutual SSL authentication using tomcat. I tried google and stackoverflow for the answer but I haven't been lucky so far. I have done the following steps
1. Generated a self signed Certificate using the command as...
Result(DOS Output):
2. Generated the developer key by using the command as...
3 Exported and saved the certificate in dev.cer keytool -export -alias developerKey -keystore dev.p12 -storetype PKCS12 -storepass dev123 -rfc -file dev.cer
4.Imported dev.cer in the keystore as using the command as... and selected y keytool -import -v -file dev.cer -keystore tomcat.keystore -storepass server123
5.Added the connecter entry to server.xml as...
6. Started Tomcat, firefox and on Tools->Options->Advanced->View Certificates->Your Certificate->import, imported the dev.p12 file Result: asked me for the password which I entered as dev123 then i hit next, next till finish
If in the server.xml I change the attribute clientAuth to false then the web page opens correctly.
Any help will be appreciatedI am using tomcat7 with eclipse indigo OS windows 7If any more details/screenshot is required I will happily provide
Ken Y-N8,0851313 gold badges4747 silver badges7878 bronze badges
Keshav JhaKeshav Jha
1 Answer
The ssl_error_bad_cert_alert error in this case means the server doesn't trust your self-signed cert. One way to solve this is to generate certs and CSR's, and then sign them with a local development CA. Then you just add your dev CA to the JVM truststore. It is slightly more setup, but is more flexible (e.g., you can create signed certs for a whole development team, test revocation via OCSP/CRL, etc).
These steps are copied from my history and probably require changes:
Create a local dev CA
Generate client and server keystores with a keypair in each
Generate client and server cert signing requests (csr) based on above keystore keypairs
Sign the requests (create certs) for client/server csr's
Import the CA cert into client/server keystores (possibly not necessary, since it must be added to truststore anyway)
Import the client and server certs into their respective keystores
Convert the client cert to a p12 (PKCS12) so it can be imported into firefox or wherever
Import the CA cert into the JVM truststore
Optionally, import the CA cert into your browser.
Your post was hard to read because of the formatting. Hope this helps.
Sources: http://shib.kuleuven.be/docs/ssl_commands.shtml, https://docs.oracle.com/cd/E19509-01/820-3503/ggezy/index.html
andykandyk