My 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
Contents of 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
Enter sudo docker ps -a to check, the results are all
51e87164a739 feiyu/django-app "/usr/bin/tini -- ..." 5 minutes ago Exited (127) 8 seconds ago django
It exits as soon as it runs. What's going on? what to do?
滿天的星座2017-05-16 13:19:29
You need to have the Docker container run in a daemonized state in the background, which can be achieved by adding the -d parameter
$ sudo docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
Pay attention here/bin/sh -c "while true; do echo hello world; sleep 1; done"