我是Docker的新手。我的Dockerfile(来自教程)是:
FROM ubuntu
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends apache2 \
libapache2-mod-jk
VOLUME ["/var/log/apache2"]
RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf
EXPOSE 80 443
ENTRYPOINT ["apache2ctl", "-D", "FOREGROUND"]
我给了docker build -t mg:httpd apache\
。没有错误。
λ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mg httpd 262d7a4f85fc About an hour ago 248MB
docker run -it mg:httpd
没有错误,但光标立即返回到命令提示符。在浏览器中获取Unable to connect
http://localhost/
。
λ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
600231bbd461 mg:httpd "apache2ctl -D FOR..." 2 minutes ago Exited (0) 2 minutes ago
泊坞窗日志为空
λ docker events
2017-09-08T15:26:10.726720800+05:30 container create 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (image=mg:httpd, name=zealous_ritchie)
2017-09-08T15:26:10.740310700+05:30 container attach 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (image=mg:httpd, name=zealous_ritchie)
2017-09-08T15:26:11.035777100+05:30 network connect 2b8829b336575a2aa2210f55105d793e8f1b196d51845d38d3dc8ff322af6143 (container=5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157, name=bridge, type=bridge)
2017-09-08T15:26:11.090873500+05:30 volume mount e8421cbd867fca04f0dd3ee6da815c59cad5fc32c5a427710d144213b43caa26 (container=5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157, destination=/var/log/apache2, driver=local, propagation=, read/write=true)
2017-09-08T15:26:11.548736900+05:30 container start 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (image=mg:httpd, name=zealous_ritchie)
2017-09-08T15:26:11.573272300+05:30 container resize 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (height=41, image=mg:httpd, name=zealous_ritchie, width=168)
2017-09-08T15:26:12.733164900+05:30 container die 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (exitCode=0, image=mg:httpd, name=zealous_ritchie)
2017-09-08T15:26:13.227455500+05:30 network disconnect 2b8829b336575a2aa2210f55105d793e8f1b196d51845d38d3dc8ff322af6143 (container=5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157, name=bridge, type=bridge)
2017-09-08T15:26:13.306885700+05:30 volume unmount e8421cbd867fca04f0dd3ee6da815c59cad5fc32c5a427710d144213b43caa26 (container=5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157, driver=local)
可能是什么原因?当容器未启动时,如何查看apache log \ conf文件?
答案 0 :(得分:2)
因此,您的Web服务器不是作为前台进程的startet,这就是容器立即停止的原因。
我认为你应该改变
a = np.random.randint(10, size=(100,100,100)) #axes x,y,z
N = 5
maxima = np.zeros((100,100,N)) #container for mean of N max values along axis z
for x in range(100): #loop through x axis
for y in range(100): #loop through y axis
max_idx = a[x, y, :].argsort()[-N:] #indices of N max values along z axis
maxima[x, y, :] = a[x, y , max_idx] #extract values
result = np.mean(maxima, axis = 2) #take the mean
到
ENTRYPOINT ["apache2ctl", "-D", "FOREGROUND"]
因为您希望在装载容器时运行该命令。
CMD ["apache2ctl", "-D", "FOREGROUND"]
指令声明用于执行ENTRYPOINT
的可执行文件。
CMD
我能找到的Ubuntu图片default command是ENTRYPOINT ["apache2ctl", "-D", "FOREGROUND"]
results in:
$ apache2ctl -D FOREGROUND <command either from the run command line or the CMD directive>
。
所以当你使用:
/bin/bash
执行的结果命令为:
docker run -it mg:httpd
显然没有多大意义。我建议过that帖子,它很好地解释了细节。
在上述变化之后,它将如下所示:
$ apache2ctl -D FOREGROUND /bin/bash
答案 1 :(得分:0)
当您以交互方式运行容器时会发生这种情况,因为这样可以将SIGWINCH
信号从主机转发到容器。 Apache使用SIGWINCH
来表示正常关闭。我提供了完整的答案here。