21
Docker Compose - Ubuntu LAMP Setup on Windows
This setup is only for local development, so I didn't add any security-related layers to it.
My Directory Structure for this setup was like this.
lamp/
├─ Dockerfile
├─ docker-compose.yml
├─ 000-default.conf
After setting up (copy the given files below) or download it from here. Then switch to the lamp directory and issue the following command.
docker-compose up
File Name: Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
ENV DEBIAN_FRONTEND=noninteractive | |
ENV TZ=Asia/Kolkata | |
LABEL maintainer="vkuberan@gmail.com" | |
CMD echo "Installing Latest Ubuntu along with Apache and PHP...." | |
RUN apt-get update && apt-get upgrade | |
RUN apt-get install -y \ | |
iputils-ping \ | |
vim \ | |
systemctl \ | |
git \ | |
apache2 \ | |
apache2-utils \ | |
mariadb-client \ | |
php \ | |
libapache2-mod-php \ | |
php-mysql \ | |
php-curl \ | |
php-gd \ | |
php-mbstring \ | |
php-xml \ | |
php-soap \ | |
php-intl \ | |
php-zip | |
COPY 000-default.conf /etc/apache2/sites-available/ | |
CMD a2enmod rewrite | |
CMD systemctl restart apache2 | |
RUN apt clean | |
EXPOSE 80 | |
ENTRYPOINT apachectl -D FOREGROUND |
File Name: docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
ubuntu: | |
build: . | |
container_name: ubuntu_stack | |
restart: unless-stopped | |
stdin_open: true | |
tty: true | |
volumes: | |
- ./webroot:/var/www/html/ | |
ports: | |
- 8085:80 | |
networks: | |
- ubuntustack | |
mariadb: | |
image: mariadb:latest | |
container_name: ubuntu_stack_maria_db | |
restart: unless-stopped | |
ports: | |
- 33063:3306 | |
environment: | |
- MARIADB_USER=root | |
- MARIADB_PASSWORD=root | |
- MARIADB_ROOT_PASSWORD=root | |
networks: | |
- ubuntustack | |
phpmyadmin: | |
image: phpmyadmin/phpmyadmin:latest | |
container_name: ubuntu_stack_php_my_admin | |
restart: unless-stopped | |
ports: | |
- 2599:80 | |
environment: | |
- PMA_ARBITRARY=1 | |
networks: | |
- ubuntustack | |
networks: | |
ubuntustack: | |
name: ubuntu_stack_network | |
driver: bridge | |
volumes: | |
ubuntu: | |
name: htdocs |
File Name: 000-default.conf
This file is used to enable rewriteurl feature in /var/www/html/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
# The ServerName directive sets the request scheme, hostname and port that | |
# the server uses to identify itself. This is used when creating | |
# redirection URLs. In the context of virtual hosts, the ServerName | |
# specifies what hostname must appear in the request's Host: header to | |
# match this virtual host. For the default virtual host (this file) this | |
# value is not decisive as it is used as a last resort host regardless. | |
# However, you must set it for any further virtual host explicitly. | |
# ServerName www.example.com | |
ServerAdmin webmaster@localhost | |
DocumentRoot /var/www/html | |
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn, | |
# error, crit, alert, emerg. | |
# It is also possible to configure the loglevel for particular | |
# modules, e.g. | |
# LogLevel info ssl:warn | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
<Directory /var/www/html> | |
Options Indexes FollowSymLinks | |
AllowOverride all | |
Require all granted | |
</Directory> | |
# For most configuration files from conf-available/, which are | |
# enabled or disabled at a global level, it is possible to | |
# include a line for only one particular virtual host. For example the | |
# following line enables the CGI configuration for this host only | |
# after it has been globally disabled with "a2disconf". | |
# Include conf-available/serve-cgi-bin.conf | |
</VirtualHost> |
21