Skip to content

Instantly share code, notes, and snippets.

@faizalmansor
Last active March 20, 2018 07:41
Show Gist options
  • Save faizalmansor/4b856ceecd845cec97b360a37e377b36 to your computer and use it in GitHub Desktop.
Save faizalmansor/4b856ceecd845cec97b360a37e377b36 to your computer and use it in GitHub Desktop.
Learning Docker by creating Linux, NGINX, MySQL & PHP (LEMP) containers

LEMP Docker Setup

Adapted from:

http://linoxide.com/containers/setup-lemp-stack-docker/

Resources:

https://docs.docker.com/engine/getstarted/step_four/#step-1-write-a-dockerfile

Install docker

Start docker service

Folder Setup

  1. Create a root directory by the name LEMP-Docker and a single file docker-compose.yml inside it
  2. For NGINX logs, create a directory by the name "logs" inside LEMP-Docker and create two files nginx-access.log and nginx-error.log inside logs directory.
  3. For NGINX config file, create a directory by the name "sites-available" inside LEMP-Docker and create a default config file.
  4. At last for your PHP files create a directory by the name public_html inside LEMP-Docker. We will place PHP files in this directory at later stage.

So our directory structure looks like the following:

LEMP-Docker/
├── docker-compose.yml
├── logs
│   ├── nginx-access.log
│   └── nginx-error.log
├── public_html
│   └── index.php
└── sites-available
    └── default

Next, edit your docker-compose.yml with the following entry:

nginx:
   image: tutum/nginx
   ports:
     - "80:80"
   volumes:
     - ./sites-available/default:/etc/nginx/sites-available/default
     - ./sites-available/default:/etc/nginx/sites-enabled/default
     - ./logs/nginx-error.log:/var/log/nginx/error.log
     - ./logs/nginx-access.log:/var/log/nginx/access.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment