- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个 docker 文件,当我构建和运行容器时,容器立即退出。
我使用 Ubuntu 18.04 作为安装 docker 的基本操作系统。
我的 docker 文件包含以下内容
FROM ubuntu <br>
RUN apt-get update <br>
RUN apt-get install apache2 -y <br>
RUN apt-get install apache2-utils -y <br>
RUN apt-get clean <br>
RUN rm -rf /var/lib/apt/lists/* <br>
EXPOSE 80 <br>
ENTRYPOINT ["apache2ctl"] <br>
CMD ["/usr/sbin/apache2ctl", "-DFOREGROUND"] <br>
sudo docker build -t myimage
.
sudo docker run -it -p 80:80 myimage
sudo docker ps -a <br>
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES 6b1891ac8195 myimage "apache2ctl /usr/sbi…"
15 minutes ago Exited (1) 15 minutes ago
infallible_williamson
dc3cc1328508 5b5570dec3a9
"tail -f /dev/null /…" 17 minutes ago Exited (1) 17 minutes ago stoic_ganguly
a67f5cb9f080 53a1c1ddc4fc "tail -f /dev/null /…" 18 minutes ago Exited (1) 18 minutes ago
vibrant_grothendieck
07fa216c6c00 b5d19c3240f7
"apache2ctl /usr/sbi…" 31 minutes ago Exited (1) 31 minutes ago keen_blackburn
71d686cb0b8e 568c96482f1c
"apache2ctl /bin/sh …" 39 minutes ago Exited (1) 38 minutes ago happy_saha
11e0abe7c2ec d056b6f1d824 "apache2ctl /bin/sh …" 40 minutes ago Exited (1) 40 minutes ago
vibrant_kare
17ed24e8eef4 d056b6f1d824 "apache2ctl /bin/sh …" 3 hours ago Exited (1) 3 hours ago
gallant_dijkstra
b1c6d9bf2765 d056b6f1d824
"apache2ctl /bin/sh …" 3 hours ago Exited (1) 3 hours ago
elated_joliot
最佳答案
在你的 Dockerfile 中需要纠正的地方很少
Use specific versions for your base images
FROM ubuntu:18.04
将特定版本添加到您的 FROM
图片 ,这有助于理解
这个 Docker 镜像是用什么版本的基础镜像 (Ubuntu:18.04
) 构建的 .
Combine multiple
RUN
commands
RUN
单个 RUN
的命令命令 ,如果可能的话,有助于减少 docker 层的数量,从而减少图像的大小。
RUN apt-get update
RUN apt-get install apache2 -y
RUN apt-get install apache2-utils -y
RUN apt-get update && \
apt-get install -y apache2 apache2-utils && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
CMD correction
apache2ctl
在您的
ENTRYPOINT
无需在您的CMD
中再次提及 .您的
命令被解释为
apache2ctl /usr/sbin/apache2ctl -DFOREGROUND
.因此 docker
run
命令失败。
Dockerfile
被修改:
$ cat Dockerfile
FROM ubuntu:18.04
RUN apt-get update && \
apt-get install -y apache2 apache2-utils && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
EXPOSE 80
ENTRYPOINT ["apache2ctl"]
CMD ["-DFOREGROUND"]
$ docker build -t myimage:1.0 .
Sending build context to Docker daemon 38.3MB
Step 1/5 : FROM ubuntu:18.04
---> cf0f3ca922e0
Step 2/5 : RUN apt-get update && apt-get install -y apache2 apache2-utils && apt-get clean && rm -rf /var/lib/apt/lists/*
---> Using cache
---> 2f47b3a5e735
Step 3/5 : EXPOSE 80
---> Using cache
---> 5b395b19a0dc
Step 4/5 : ENTRYPOINT ["apache2ctl"]
---> Using cache
---> be1afc8d76c3
Step 5/5 : CMD ["-DFOREGROUND"]
---> Running in 3d0d78c566e2
Removing intermediate container 3d0d78c566e2
---> 00167996f7f3
Successfully built 00167996f7f3
Successfully tagged myimage:1.0
-d
,作为在后台运行进程。
$ docker run -d -p 80:80 myimage:1.0
eccb77059f9ce8628e7a47d64adb9d20a3ca6cb3cecce06935b46eb13652b992
$ docker ps | grep eccb77
eccb77059f9c myimage:1.0 "apache2ctl -DFOREGR…" 14 seconds ago Up 12 seconds 0.0.0.0:80->80/tcp charming_payne
$ docker ps | grep eccb77
eccb77059f9c myimage:1.0 "apache2ctl -DFOREGR…" 27 seconds ago Up 25 seconds 0.0.0.0:80->80/tcp charming_payne
$ docker ps | grep eccb77
eccb77059f9c myimage:1.0 "apache2ctl -DFOREGR…" 4 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp charming_payne
$ curl http://localhost:80
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Modified from the Debian original for Ubuntu
Last updated: 2016-11-16
See: https://launchpad.net/bugs/1288690
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Apache2 Ubuntu Default Page: It works</title>
<style type="text/css" media="screen">
* {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
关于ubuntu - Docker Apache Container 在 Ubuntu 18.04 上立即存在(从 Docker 文件构建),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58834494/
大家好,所有rdf/sparql开发人员。这是一个困扰了我一段时间的问题,但是自从发布rdf和sparql规范以来,似乎没人能准确回答这个问题。 为了说明这种情况,RDF定义了几种方法来处理资源的多值
我在我的应用程序中使用 Bootstrap ,现在遇到了一个大问题。问题是 .container 元素在 1360 px 的屏幕上具有 274px 的左右边距,这是相当大的。结果,一切看起来都被挤到了
我在删除Docker容器时遇到问题-当我使用前一个命令时,它不起作用(Docker报告了容器ID,但没有删除它)。后者起作用了。据我所知,Docker语法是相同的: C:\Users\user>doc
std::back_inserter 仅适用于带有 push_back 的容器,因此它不适用于 set 和 map 另一方面,std::inserter 适用于所有容器类型。那么我可以一直使用 std
我正在开发 Spring Boot + Redis 示例。在此示例中,我开发了一些自定义方法,这些方法基于 RoleName 提取详细信息。对于以下方法 userRepository.findByRo
在我的 Swift 应用程序中尝试实现 Google Tag Manager v5 时,我遇到了以下警告,这给我带来了一些麻烦: GoogleTagManager warning: No defaul
安装了新的 Laravel 8 项目并在加载第一个实例时,出现以下错误。这很奇怪,因为我把它放在一边,后来从 Laravel 5.8 -> 6 升级了另一个项目(工作正常),当我去检查网站时遇到了类似
我有以下测试代码,它只创建一个空的 hashmap (containers.map) 并在之后填充它: hashtable = containers.Map('KeyType','char','Va
我对它们之间的差异有一点了解,但是拥有专家意见将是很棒的。 Container-Optimized Google Compute Engine Images Google Container Engi
我会模板化一个函数,以便将它与 vector、set 或任何其他 STL 容器(具有正确的 API...)一起使用 我的函数当前原型(prototype)是: vector> f ( const ve
我正在尝试匹配包含和不包含某些字符串的 Pandas DataFrame 的行。例如: import pandas df = pandas.Series(['ab1', 'ab2', 'b2', 'c
我需要在一个非常庞大的全文索引数据库中找到一些文本,但我不知道在我的查询术语变体中使用什么更好。 我看过一些使用的例子 SELECT Foo.Bar FROM Foo WHERE
Traceback (most recent call last): File "demo.py", line 132, in `result = find_strawberry(image
我正在尝试编写一个函数,其中一列包含一个子字符串并且不包含另一个子字符串。 在下面的示例中,如果我的行包含“某些项目”并且不包含“开销”,我希望我的函数返回 1。 row| example strin
我试图在文本文件中 append 包含给定字符串集的任何行。我创建了一个测试文件,在其中放置了这些字符串之一。我的代码应该将文本文件中包含这些字符串之一的任何行打印在与文本文件中的上一行相同的行上。这
我正在尝试学习如何使用 std.container 中可用的各种容器结构,但我无法理解如何执行以下操作: 1) 如何创建一个空容器?例如,假设我有一个用户定义的类 Foo,并且想要创建一个应该包含 F
$contains: [1, 2] // @> [1, 2] (PG array contains operator) $contained: [1, 2] // <@ [1,
我看到 CSS 中使用了这种“div#container”语法,我想知道它是如何工作的。有人有它的资源吗? 最佳答案 除了作为上面提到的唯一引用之外,ID 还增加了特异性(我强烈建议您阅读这篇文章或一
我有一个生成很多子对象的应用程序,每个子对象都与一些全局应用程序对象一起工作,例如在全局应用程序注册表中注册自己,更新应用程序统计信息等。 应用程序应该如何将访问这些全局对象的能力传递给 child
Here is a Sencha fiddle of my tab panel setup.按钮被动态添加到 vbox 选项卡容器中,该容器是 hbox 布局设置的一部分。选项卡容器的宽度由 flex
我是一名优秀的程序员,十分优秀!