8
8

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入門: 4日目

Posted at

コンテナにNginxを入れてブラウザで閲覧

コンテナ作成、Nginxをインストール

$ docker run -it -p 8080:80 intern/sshd /bin/bash

root@0d4430a80668:/# aptitude install -y nginx
...
Setting up xml-core (0.13+nmu2) ...
Processing triggers for sgml-base ...

root@0d4430a80668:/# 

Nginxの設定、起動

バーチャルサーバの設定を書きます。

root@0d4430a80668:/# vim /etc/nginx/conf.d/default.conf
/etc/nginx/conf.d/default.conf
server {
  listen  80;
  server_name localhost;

  location / {
    root /usr/share/nginx/www;
    index index.html;
  }
}

ブラウザで閲覧

起動。

root@0d4430a80668:/# /etc/init.d/nginx start
Starting nginx: nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
nginx.

root@0d4430a80668:/# 

ブラウザで開く。

スクリーンショット 2014-07-08 11.31.09.png

アクセスするURLは...

$ boot2docker ip

The VM's Host only interface IP address is: 192.168.59.103

$ docker ps
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS                  NAMES
0d4430a80668        intern/sshd:latest   /bin/bash           17 hours ago        Up 16 minutes       0.0.0.0:8080->80/tcp   romantic_elion  

参考

Dockerの参考

Nginxの参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?