2017-05-27 3 views
-1

ドッキング用のコンテナを作成して、ユーザーにdocker run...と入力するだけで、どのシステムでもHTMLファイルを実行できます。 これは、HTMLコードです:Docker - ドッカーでHTMLファイルを実行

<!doctype html> 
<html> 
    <style> 
    body { 
     padding: 20px 5%; 
     color: white; 
     font-family: Sabon, serif; 
     margin: auto; 
     max-width: 800px; 
    } 
    @media (min-width: 600px) { 
    } 
    </style> 
    <head> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>D & T</title> 
    </head> 
    <body> 
    <center> 
    <div id="headline"> 
     <header> 
     <h1>Date and Time</h1> 
     <p></p> 
     </header> 
     <div id="blurb"> 
     <p>This page will show you your current local time.</p> 
     </div> 
    </div> 
    <div id="section1"> 
     <h2></h2> 
     <p>It is now</p> 
    </div> 
    <div id="section2"> 
     <script type="text/javascript"> 
     document.write ('<p>----<span id="date-time">', new Date().toLocaleString(), '<\/span>----<\/p>') 
     if (document.getElementById) onload = function() { 
    setInterval ("document.getElementById ('date-time').firstChild.data = new Date().toLocaleString()", 50) 
     } 
     </script> 
    </div> 
    <div id="section3"> 
     <div style="position: absolute; bottom: 5px"> 
     <i>RG</i> 
     </div> 
    </div> 
    <footer> 
     <p><i>Created 26 May 2017</i></p> 
    </footer> 
    </center> 
    </body> 
</html> 

私は現在のUbuntu 14.04環境を使用してHTMLファイルを開こうとlinks2を取得するためにwgetのを使用して、その後、htmlファイルを開くにはのxdg-オープンを使用しています。しかし、私はページを取得していない。 docker run...は何もしません。エラーはありませんが、Webページもありません。 これは私のDockerfileです:

FROM ubuntu:14.04 

WORKDIR /app 

ADD . /app 

USER root 

RUN apt-get update 

RUN apt-get install --no-install-recommends xdg-utils 

RUN apt-get install -y --no-install-recommends links2 

RUN xdg-open datetime.html 

任意の代替または正解?

+1

を参照してください。ファイルがそのフォルダに移動し、実行可能な状態になりますとき

FROM ubuntu:14.04 COPY index.html /var/www/html/ 

:あなたのDockerfileは次のようになります。 ?このhtmlをブラウザに表示したいのですか? – arbogastes

+0

はい、ブラウザにあります。それも可能ですか? – user7091463

答えて

0

HTML(apacheまたはnginx)を公開するにはサービスが必要です。 $ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginxを実行するだけで、some/contentがHTMLファイルにリンクします。ここでは公式のnginxのドッキングウィンドウへのリンクです:https://hub.docker.com/_/nginx/

+0

私は公式のNginxドッカーの指示に従いましたが、 'docker run --name xyz -d -p 8080:80 abc'を実行した後、' 8ezsh23dfg4fgh23 ... 'のような長い文字列を取得しました。それは意味ですか? – user7091463

0

は、あなたがマシンのIPをドッキングウィンドウチェック:

docker-machine ip 

それは、例えば与える:あなたがチェックすることができ192.168.99.100あなたのコンテナが指定されたIPで、その後runingてます結果(例:http://192.168.99.100/) Dockerfileと同じフォルダにindex.htmlファイルを置きます。 - あなたは何を意味しています

docker build -t my_html_file . 
docker run -p 80:80 my_html_file 

そして、「HTMLファイルを実行する」http://192.168.99.100/

+0

私はどのように 'ip'を訪問するのですか?のように、どこに正確に入力しますか?私は上記を行いましたが、 'docker run -p 80:80 my_html_file'を実行した後、私は何も得ません。ちょうど新しいコマンドライン。 – user7091463

+0

@ user7091463ブラウザを開き、あなたのhtmlを表示するためにあなたのアドレスipを貼り付けてください。 – arbogastes

関連する問題