Docker 图片不会 运行 在背景中

Docker images wont run in background

我创建了我的第一个 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 入口点,bash 将在标准输入 returns 文件末尾时立即退出。所以你离开它运行ning,你需要用docker run -itd image-name开始它。 -i 使其具有交互性,-t 分配一个 tty,-d 分离。这使标准输入在容器上保持打开状态,并允许您对容器附加或执行命令。

跟进:我刚刚看到你的命令 --port 81,当 运行 作为 bash 上的命令时,会给你一个无效的选项。如果您需要 运行 mongo 作为一个选项,您将需要一个不同的入口点。