LoginSignup
12
9

More than 5 years have passed since last update.

Docker for MacでPHPの開発環境を起動する

Last updated at Posted at 2017-08-09

こんにちは、れおりんです。

[第2回]CakePHP3もくもく勉強会 で説明した内
容を掲載します。

シンプルなPHPのプログラムをApacheとPostgreSQLで起動します。

Install Docker for Mac
Stable(安定版)を最初にインストールしてください。

html/index.php

<?php

phpinfo();

docker/Dockerfile

FROM php:7-apache

RUN set -x && \
  apt-get -y update && \
  apt-get install -y libicu-dev postgresql-server-dev-9.4 && \
  NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
  docker-php-ext-install -j${NPROC} intl && \
  docker-php-ext-install -j${NPROC} pdo_pgsql && \
  docker-php-ext-install -j${NPROC} pdo_mysql && \
  rm -rf /tmp/pear

docker-compose.yml

version: '3.1'
services:
  web:
    build:
      context: ./docker
    volumes:
      - ./html:/var/www/html
    ports:
      - "80:80"
    depends_on:
      - db
    tty: true
    stdin_open: true

  db:
    image: postgres:9.6.1
    ports:
      - "5432:5432"
    environment:
      POSTGRES_PASSWORD: dbpass
      POSTGRES_DB: docker_test

起動方法

docker-compose up

止める方法

docker-compose stop

環境を削除する方法

docker-compose rm
12
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
9