LoginSignup
3
9

More than 5 years have passed since last update.

dockerでサクッとwebサイトを立ち上げる

Last updated at Posted at 2017-06-19

Overview

docker公式のapacheイメージを使用して静的なWebサイトを立ち上げます

Environments

使用するイメージ : https://github.com/docker-library/httpd
立ち上げるサイト : https://github.com/themefisher/timer-html

Actions

  • まずはイメージのリポジトリをクローン
    apacheのバージョンが2.2と2.4がありますが、ここは2.4で
git clone https://github.com/docker-library/httpd.git
cd httpd/2.4
sudo docker build -t apache24 .

ディレクトリ内には
alpine Dockerfile httpd-foreground
があり、このDockerfileの記述を基にイメージが作成されます。ビルドはそこそこ時間がかかります
-tオプションは作成するイメージに名前をつけているだけです

  • 立ち上げたいサイトをクローン + コンテナを起動
git clone https://github.com/themefisher/timer-html.git
sudo docker run -itd -p 80:80 -v ~/timer-html:/usr/local/apache2/htdocs apache24 httpd-foreground

イメージからコンテナを立ち上げます
コンテナを起動しつつ、apacheのプロセスを立ち上げ、Webサイトのファイルをコンテナにマウントし、ポートフォワードしてます

コマンドが長い?むしろこれだけでwebサイトが立ち上げられるんです。技術の進歩に感謝しましょう

3
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
3
9