Spread the love


Yesterday evening I decided to spend time on setting up LAMP( Linux, Apache, MySQL and PHP) stack inside a docker container.

I managed to create a CentOS 7.0 VM with around 50GB space and around 4GB RAM. I had enough containers lying around and so removed few which I no longer needed. Here is the dirty guide on how I was able to setup LAMP stack on my docker system.

Let’s start searching for LAMP.  I just uploaded a LAMP container onto the Docker hub at https://registry.hub.docker.com/u/collabnix/lamp-for-collabnix/

[root@localhost ~]# docker search collabnix
collabnix/lamp-for-collabnix 0
collabnix/puppet4docker A Puppet Ready Docker Image 0
collabnix/puppet-for-docker 0

Let’s pull the docker image:

[root@localhost ~]# docker pull collabnix/lamp-for-collabnix:v1.0
Pulling repository collabnix/lamp-for-collabnix
17d8d9272e36: Pulling image (v1.0) from collabnix/lamp-for-collabnix, endpoint: 17d8d9272e36: Download complete
c50f7e0846e6: Download complete
fd248b999044: Download complete
9f91f850df24: Download complete
ac6b0eaa3203: Download complete
Status: Image is up to date for collabnix/lamp-for-collabnix:v1.0
[root@localhost ~]#

Let’s run the docker image and expose 80:80 port for Apache to work:

[root@localhost ~]#sudo docker run -p 80:80 -t -i collabnix/lamp-for-collabnix:v1.0 /bin/bash

Starting Apache Service:

root@c1b6750b55:/# service apache2 restart
* Restarting web server apache2
/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
Setting ulimit failed. See README.Debian for more information.
[ OK ]

In worst case, if you face the above issue, here is the fix:

change /etc/apache2/envvars entry to APACHE_ULIMIT_MAX_FILES=’sleep 0.01′

#service apache2 restart
* Restarting web server apache2 [ OK ]

Starting MySQL:

#service mysql start

* Starting MySQL database server mysqld [ OK ]
* Checking for tables which need an upgrade, are corrupt or were
not closed cleanly.

Now, you can exit the container while leaving it running by pressing ctrl + p then ctrl + q.

Enter the IP address in a web browser to test the site.

Done !!! You have LAMP stack working in a Docker container.


Spread the love
Categories: Docker

Ajeet Raina

My name is Ajeet Singh Raina and I am an author of this blogging site. I am a Docker Captain, ARM Innovator & Docker Bangalore Community Leader. I bagged 2 special awards last year(2019): Firstly, “The Tip of Captain’s Hat Award” at Dockercon 2019, San Francisco, and secondly, “2019 Docker Community Award“. I run Collabnix Community Slack with over 5300+ audience . I have built popular GITHUB repositories like DockerLabs, KubeLabs, Kubetools, RedisPlanet Terraform etc. with the support of Collabnix Community. Currently working as Developer Relations Manager at Redis Labs where I help customers and community members adopt Redis. With over 12,000+ followers over LinkedIn & close to 5100+ twitter followers, I like sharing Docker and Kubernetes related content . You can follow me on Twitter(@ajeetsraina) & GitHub(@ajeetraina)

1 Comment

Bella Vita · 6th August 2016 at 8:05 am

This website is amazing. I will tell about it to my friends and anybody that could be interested in this subject. Great work guys!

Leave a Reply

Your email address will not be published. Required fields are marked *

Hey, Wait !

Stay Informed about what's happening around DevOps community and tools.