Dockerでふるーーいphp5.2環境の構築

PHPの古い環境用意するのに、調べたこと、やったことをメモ。
参考
これだとurlがrewriteに対応していないので追加
docker pull image
dockerイメージを取得します
docker pull tommylau/nginx
docker pull mysql:5.7
docker image list
itkaasan@itkaasan-ThinkPad:~/work/$ docker image list REPOSITORY TAG IMAGE ID CREATED SIZE mysql 5.7 2f52e94d8acb 12 days ago 373MB tommylau/nginx latest 75d215ac1943 12 months ago 109MB tommylau/php-5.2 latest 7e7ee5c92d52 13 months ago 371MB
my.cnfとnginxの設定ファイルをコンテナからコピー
MySQLの設定ファイルとnginxの設定を上書きしたいので設定ファイルをコンテナからマシンにコピーします、
※取り急ぎコピーして作ったものを記事の一番最後に貼っておきます
docker cpコマンドにて設定ファイルを複製しました。
あとはこのファイルをカレントディレクトリに置いて、起動させます
hogeディレクトリを、マウントディレクトリとしてrunコマンドで起動・開始します
mysql5.7コンテナを作成
hogehogeという名称のDBも一緒に作成しました
mysql5.7とリンクしながらphp5.2の入ったコンテナを起動
php5.2とリンクしつつ、nginxを起動
http://localhost:9000
で、アクセスできます
取り急ぎ無事動きを確認してからと思ったのでdocker-composeに対応していません。。今度対応しよう。。
docker -v オプションで、コンテナにファイルを上書きできるっていうのは初めて知った。
nginxの設定ファイルとmysqlの設定ファイル
server { | |
listen 80; | |
root /var/www/html; | |
index index.html index.htm index.php; | |
server_name localhost; | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
#try_files $uri $uri/ =404; | |
try_files $uri $uri/ /index.php?$uri&$args; | |
# Uncomment to enable naxsi on this location | |
# include /etc/nginx/naxsi.rules | |
} | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass php:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
} |
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html | |
# MySQL5.7のデフォルトのmy.cnfを複製して、only_full_group_byデフォルトoff | |
# This will be passed to all mysql clients | |
# It has been reported that passwords should be enclosed with ticks/quotes | |
# escpecially if they contain "#" chars... | |
# Remember to edit /etc/mysql/debian.cnf when changing the socket location. | |
# Here is entries for some specific programs | |
# The following values assume you have at least 32M ram | |
!includedir /etc/mysql/conf.d/ | |
[mysqld] | |
character-set-server=utf8 | |
sql_mode='' | |
[mysqldump] | |
default-character-set=utf8 | |
[mysql] | |
default-character-set=utf8 |