LoginSignup
8
5

More than 3 years have passed since last update.

とりあえずhtmlの表示をDocker使って行う[nginxバージョン]

Last updated at Posted at 2019-01-13

htmlなんてDocker使わなくても…って思うかもですが、
Dockerになれるため一回htmlを表示しようをやる(◍•ᴗ•◍)

参考:https://hub.docker.com/_/nginx

ファイル構成
スクリーンショット 2019-01-13 22.55.44.png

スクリーンショット 2019-01-13 22.59.56.png

$ docker run hello-world打てる状態のところからの解説になります。
自分なりに説明したもの、https://qiita.com/sachiko-kame/items/35e0cf07d117c3b92613
で書いてます。

ファイル中身

Dockerfile
FROM nginx
COPY static-html-directory /usr/share/nginx/html
index.html
<!DOCTYPE HTML>
<html lang="ja">

<head>
  <meta charset="UTF-8">
  <title>title</title>
</head>

<body>
  hello (。・ω・。)
</body>

</html>

いざ起動!

$ docker build -t some-content-nginx .
説明:Dockerfileがいるところに行って、現在のDockerfileのイメージを作成。tag名は[some-content-nginx]

$ docker run --name some-nginx -d -p 8080:80 some-content-nginx
説明:次に、起動。作成されたイメージ[some-content-nginx]を自分のローカルの8080で起動!

最後にチェック

http://[自分のipアドレス]:8080/

ipアドレスは$ docker-machine ip defaultで調べられます。

こんな表示がされましたでしょうか?

スクリーンショット 2019-01-13 23.22.03.png

github (中身のところ) cloneしてこのフォルダに行って同じようにするでも動きます(✿´ ꒳ ` )
https://github.com/sachiko-kame/dockers/tree/master/simple_nginx

8
5
9

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
8
5