Help us understand the problem. What is going on with this article?

php7.0をDockerでサクッと動かす

php7.0をDockerでサクッと動かす

参考: Docker Hubのオフィシャルイメージを使ったLAMP環境(Apache+PHP+MySQL)構築 - Qiita

Dockerイメージを取得

DockerHubから公式イメージを取得.

$ docker pull php:7.0-apache

イメージが取得できているか確認.

$ docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
php                       7.0-apache          c5a07b1726fc        4 days ago          390MB

Dockerを動かす

以下で動かす.

docker run -p 8000:80 -v $(pwd):/var/www/html --name php -d php:7.0-apache

オプションの解説

オプション 設定値 意味
-p 8000:80 ローカルの8000番をコンテナの80番にマッピング
-v $(pwd):/var/www/html 現在いる場所$(pwd)/var/www/htmlにマッピング. $(pwd)を任意のローカルパスに設定することも可能
--name php 識別しやすい任意の名称をつける
-d - デタッチ・モードで起動する

さらに詳しいことは, Docker run リファレンス — Docker-docs-ja 17.06.Beta ドキュメントに書いてる.

動作を確認

カレントディレクトリにindex.phpを作成して、内部に<?php phpinfo();と書いてブラウザから127.0.0.1:8000へアクセスしてみる.

phpinfoが表示さればOK.


Copyright (c) 2017 Tomoyuki KOYAMA
Released under the MIT license
http://opensource.org/licenses/mit-license.php

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした