泊坞窗图像惯于在后台
问题描述:
我创造了我的第一个Dockerfile运行,但是当我运行泊坞窗图像惯于在后台
sudo docker ps
容器不是在后台运行的命令,这是我dockerfile:
# Set the base image to Ubuntu
FROM debian:jessie
# File Author/Maintainer
MAINTAINER <Qop>
# Update the repository sources list
RUN apt-get update
################## BEGIN INSTALLATION ######################
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y \
vim \
apache2
##################### INSTALLATION END #####################
# Expose the default port
EXPOSE 81
# Default port to execute the entrypoint (MongoDB)
CMD ["--port 81"]
# Set default container command
ENTRYPOINT /bin/bash
答
随着bash
入口点,bdin将在stdin返回文件结尾时立即退出。所以你让它继续运行,你需要用docker run -itd image-name
来启动它。 -i
使它互动,-t
分配一个tty和-d
分离。这使stdin在容器上保持打开状态,并允许您对容器附加或执行命令。
后续行动:我刚刚看到你的命令--port 81
,当它作为bash
上的命令运行时,会给你一个无效的选项。如果你需要将mongo作为选项运行,你需要一个不同的入口点。
谢谢,这使得很多感觉! – Qop