【发布时间】:2017-10-28 09:41:35
【问题描述】:
我想构建一个 docker 容器,它可以在任何系统上运行 HTML 文件,只需要用户输入docker run...。
这是 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 文件并使用 wget 获取 links2,然后使用 xdg-open 打开 html 文件。但我没有得到页面。 docker run... 什么都不做。没有错误,但也没有网页。
这是我的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
任何替代方案或正确的解决方案?
【问题讨论】:
-
“运行一个 HTML 文件”——你是什么意思?你想在浏览器中显示这个 html 还是什么?
-
是的,在浏览器中。有可能吗?
标签: html ubuntu docker dockerfile docker-container