为什么赢了';除非我使用-I-t,否则我的docker容器不会运行吗?

为什么赢了';除非我使用-I-t,否则我的docker容器不会运行吗?,docker,dockerfile,Docker,Dockerfile,如果使用以下命令运行Dockerfile,docker容器将开始运行,一切正常 docker run --name test1 -i -t 660c93c32a 但是,如果在不使用-it的情况下运行此命令,则容器似乎不会运行,因为docker ps不会返回任何内容: docker run -d --name test1 660c93c32a 我所要做的就是运行容器,然后能够在容器中附加和/或打开一个shell 不确定问题是否在我的dockerfile中,因此已将dockerfile粘贴到下

如果使用以下命令运行Dockerfile,docker容器将开始运行,一切正常

docker run --name test1 -i -t 660c93c32a
但是,如果在不使用-it的情况下运行此命令,则容器似乎不会运行,因为docker ps不会返回任何内容:

docker run -d --name test1 660c93c32a

我所要做的就是运行容器,然后能够在容器中附加和/或打开一个shell

不确定问题是否在我的dockerfile中,因此已将dockerfile粘贴到下面

############################################################
# Dockerfile to build Ubuntu/Ansible/Django
############################################################

# Set the base image to Ansible
FROM ubuntu:16.10

# File Author / Maintainer
MAINTAINER David


# Install Ansible and Related Deps #
RUN apt-get -y update && \
    apt-get install -y python-yaml python-jinja2 python-httplib2 python-keyczar python-paramiko python-setuptools python-pkg-resources git python-pip
RUN mkdir /etc/ansible/
RUN echo '[local]\nlocalhost\n' > /etc/ansible/hosts
RUN mkdir /opt/ansible/
RUN git clone http://github.com/ansible/ansible.git /opt/ansible/ansible
WORKDIR /opt/ansible/ansible
RUN git submodule update --init
ENV PATH /opt/ansible/ansible/bin:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
ENV PYTHONPATH /opt/ansible/ansible/lib
ENV ANSIBLE_LIBRARY /opt/ansible/ansible/library

# Update the repository sources list
RUN apt-get update -y
RUN apt-get install python -y
RUN apt-get install python-dev -y
RUN apt-get install python-setuptools -y
RUN apt-get install python-pip

RUN mkdir /ansible/
WORKDIR /ansible
COPY ./ansible ./
WORKDIR /

RUN ansible-playbook -c local ansible/playbooks/installdjango.yml

ENV PROJECTNAME davidswebsite
CMD django-admin startproject $PROJECTNAME

运行容器时,CMD或ENTRYPOINT之后的命令将成为容器的$1进程。如果这个过程运行不好,您的容器将死亡。 因此,请使用以下命令检查容器日志:
docker logs


然后在
CMD django admin startproject$PROJECTNAME

中重新检查您的命令,我刚刚删除了我的答案。你的更新完全改变了问题的性质,使我的答案偏离主题,令人困惑。
############################################################
# Dockerfile to build Ubuntu/Ansible/Django
############################################################

# Set the base image to Ansible
FROM ubuntu:16.10

# File Author / Maintainer
MAINTAINER David


# Install Ansible and Related Deps #
RUN apt-get -y update && \
    apt-get install -y python-yaml python-jinja2 python-httplib2 python-keyczar python-paramiko python-setuptools python-pkg-resources git python-pip
RUN mkdir /etc/ansible/
RUN echo '[local]\nlocalhost\n' > /etc/ansible/hosts
RUN mkdir /opt/ansible/
RUN git clone http://github.com/ansible/ansible.git /opt/ansible/ansible
WORKDIR /opt/ansible/ansible
RUN git submodule update --init
ENV PATH /opt/ansible/ansible/bin:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
ENV PYTHONPATH /opt/ansible/ansible/lib
ENV ANSIBLE_LIBRARY /opt/ansible/ansible/library

# Update the repository sources list
RUN apt-get update -y
RUN apt-get install python -y
RUN apt-get install python-dev -y
RUN apt-get install python-setuptools -y
RUN apt-get install python-pip

RUN mkdir /ansible/
WORKDIR /ansible
COPY ./ansible ./
WORKDIR /

RUN ansible-playbook -c local ansible/playbooks/installdjango.yml

ENV PROJECTNAME davidswebsite
CMD django-admin startproject $PROJECTNAME