Use Docker to Build a LEMP Stack (Buildfile)
I’ve been reviewing Docker recently. As part of that review, I decided to build a LEMP stack in Docker. I use Vagrant to create an environment in which to run Docker. For this experiment I chose to create Buildfiles to create the Docker container images. I’ll be discussing the following files in this post. Vagrantfile bootstrap.sh mysql/Dockerfile mysql/mysqlpwdseed nginx/Dockerfile nginx/default nginx/wall.phpVagrantfile bootstrap.sh mysql/Dockerfile mysql/mysqlpwdseed nginx/Dockerfile nginx/default nginx/wall.php Download the Docker LEMP files as a zip (docker-lemp.zip). Spin up the Host System I start with Vagrant to spin up a host system for my Docker containers. To do this I use the following files. Vagrantfile # -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty64" config.vm.network "public_network" config.vm.provider "virtualbox" do |v| v.name = "docker LEMP" v.cpus = 1 v.memory = 512 end config.vm.provision :shell, path: "bootstrap.sh" end# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty64" config.vm.network "public_network" config.vm.provider "virtualbox" do |v| v.name = "docker LEMP" v.cpus = 1 v.memory = 512 end config.vm.provision :shell, path: "bootstrap.sh" end I start with Ubuntu and keep the size small. I create a public network to make it easier to test my LEMP setup later on. bootstrap.sh #!/usr/bin/env bash # set proxy variables #export http_proxy=http://proxy.example.com:8080 #export https_proxy=https://proxy.example.com:8080 # bootstrap ansible for convenience on the control box apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" apt-get update apt-get -y install lxc-docker # need to add proxy specifically to docker config since it doesn’t pick them up from the environment #sed … Continue reading Use Docker to Build a LEMP Stack (Buildfile)
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed