Skip to content

1. Installation

Fillip Hannisdal edited this page Nov 14, 2018 · 4 revisions

Installation

This installation assumes you have already installed Docker, and it's currently running on your machine.

.bash_profile

Place these entries in your ~/.bash_profile file and run source ~/.bash_profile to let the changes take effect.

alias docker-stop='docker stop $(docker ps -aq --filter name=php)'
alias docker-rm='docker rm $(docker ps -aq --filter name=php)'

alias php53='docker-start 53 $*'
alias php54='docker-start 54 $*'
alias php55='docker-start 55 $*'
alias php56='docker-start 56 $*'
alias php70='docker-start 70 $*'
alias php71='docker-start 71 $*'
alias php72='docker-start 72 $*'

docker-start() {
	if [[ -z "$1" ]]; then
		return
	fi

	export DOCKER_PHP_VERSION="$1"
	export DOCKER_PHP_PORT="80"

	if [[ ! -z "$2" ]]; then
		export DOCKER_PHP_PORT="$2"
	else
		if docker ps -aq --filter name=php > /dev/null 2>&1 ; then
			docker-stop && docker-rm
		fi	
	fi

	docker-compose -p "php$1" -f ~/docker-compose.yml up -d
}

docker-compose.yml

Place this file in your home directory (cd ~) Make sure to change /www/public_html to wherever your webroot is on your local drive.

version: '2'
services:
  app:
    image: "belazor/dbtech-devel:php-apache-${DOCKER_PHP_VERSION}"
    container_name: "php${DOCKER_PHP_VERSION}"
    ports:
        - "${DOCKER_PHP_PORT}:80"
    volumes:
      - "/www/public_html:/var/www/html"

macOS

If you're running macOS, you will probably want to use NFS for your Docker file mounts, as NFS offers near-native performance compared to the built-in mounting technique.

This requires a setup script, as well as a slightly different docker-compose.yml file.

Docker with NFS on macOS

Clone this wiki locally