LoginSignup
26
25

More than 5 years have passed since last update.

DockerでLAMP環境のベースイメージを作る CentOS 6.6 + Apache 2.2 + MySQL 5.6 + PHP 5.6

Last updated at Posted at 2015-02-23

こちらにソースを置いておきます。
https://github.com/teruchi/lamp-base

まずはDockerfileを用意します。

#
# LAMP Base
#
# 20150223
#   CentOS 6.6 +epel +remi
#   Apache 2.2.15
#   MySQL 5.6.23
#   PHP 5.6.6

FROM centos:6
MAINTAINER teruchi

# update yum
RUN yum update -y && \
    yum clean all

# epel repo
RUN yum install -y http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm && \
    yum clean all
COPY epel.repo /etc/yum.repos.d/

# remi repo
RUN yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && \
    yum clean all
COPY remi.repo /etc/yum.repos.d/

# mysql repo
RUN yum install -y http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm && \
    yum clean all

RUN yum install -y httpd php mysql php-mysqlnd && \
    yum clean all

後で、このイメージの上にもろもろミドルウェアを入れていくDockerfileを作るので、本当にベースの環境しか入れません。
(MySQLいらないかも?)

epel.repoはこんな感じ

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

remi.repoはこんな感じ

[remi]
name=Les RPM de remi pour Enterprise Linux 6 - $basearch
mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php56]
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 6 - $basearch
mirrorlist=http://rpms.famillecollet.com/enterprise/6/php56/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

PHP 5.6を使いたいのでremiを使いました。

そしてbuild。

docker build -t teruchi/lamp-base .

teruchi/lamp-baseの部分は適時変更してください。

epel.repo, remi.repoには必要な記述だけ残してCOPYするようにしています。
他ではsedで設定ファイルを変更しているパターンがありますが、gitでそれぞれのファイルをバージョン管理したいので、この方法が望ましいと思います。

でrun。

docker run -it --rm teruchi/lamp-base /bin/bash

ベースイメージなのでここで何するわけではないけど、動作確認のため。

GitHubに上げてあるので、checkoutして微調整後、docker buildすることをお勧めします。

26
25
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
26
25