2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dockerを使ってwebサーバーたててみたときのメモ

Last updated at Posted at 2016-10-30

テキトーです

やること

Webサーバーを立ててみる

ホスト側環境

Dockerはインストール済みということで。
foderaでやってます

cat /etc/redhat-release

->Fedora release 24 (Twenty Four)

Webサーバーたててみる

centosにapacheをインストール
Dockerファイル作成、中身はこんな感じ
(@Ikumi 様ありがとうございました!)

FROM centos:7
RUN yum -y update && \
    yum -y install httpd
EXPOSE 80
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]

※centos6の場合は「FROM centos:7」を「FROM centos:6」に変更
イメージ作成

docker build -t イメージ名 ./

コンテナ起動

docker run -d -p 80:80 --name コンテナ名 イメージ名

コンテナのアドレス確認

docker inspect --format="{{ .NetworkSettings.IPAddress }}" コンテナID

ブラウザで上記アドレスにリクエスト
終わり!

次回は、アプリケーションサーバーとDBサーバーに挑戦!

2
4
4

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
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?