我的Dockerfile:
FROM continuumio/miniconda:latest
MAINTAINER Kamil Kwiek <kamil.kwiek@continuum.io>
ADD backend.tar.gz /usr/src/
# app 所在目录
WORKDIR /usr/src/backend
# 安装miniconda,配置conda 环境
RUN apt-get install -y gcc g++
COPY backend_uwsgi.ini /usr/src/backend/
COPY environment.txt /usr/src/backend/environment.txt
RUN conda env create -f /usr/src/backend/environment.txt
start.sh的内容:
#!/bin/bash
#
docker exec -d mysql mysql -uroot -p123456 -e "create database blog;"
docker build -t feiyu/django-app .
docker run --name django \
-v /usr/src/backend \
-v /usr/src/backend/static \
--link mysql:mysql \
-p 12000:8000 \
-d feiyu/django-app uwsgi --ini /usr/src/backend/backend_uwsgi.ini /bin/bash
sleep 15
#-d feiyu/django-app /usr/local/bin/gunicorn backend.wsgi:application -w 1 -b :8000
输入sudo docker ps -a 查看,结果都是
51e87164a739 feiyu/django-app "/usr/bin/tini -- ..." 5 minutes ago Exited (127) 8 seconds ago django
一运行就exit了,这是怎么回事?怎么办?
滿天的星座2017-05-16 13:19:29
需要让 Docker 容器在后台以守护态(Daemonized)形式运行,可以通过添加 -d 参数来实现
$ sudo docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
注意这里/bin/sh -c "while true; do echo hello world; sleep 1; done"