Docker-Composer退出代码0 [英] Docker-Composer exited with code 0

查看:1682
本文介绍了Docker-Composer退出代码0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始 docker-compise up Ubuntu容器退出时, ubuntu退出代码0

When I start docker-compose up the Ubuntu container exits with ubuntu exited with code 0.

当我运行 docker run -d -ti -p 80:80 -v〜/ sph / laravel52:/ www / laravel ubuntu ,一切正常。

When I run docker run -d -ti -p 80:80 -v ~/sph/laravel52:/www/laravel ubuntu, all works fine.

如何使用Docker Compose复制此行为?

How can I replicate this behavior using Docker Compose?

这是我的 Dockerfile

# Version: 0.0.1
FROM ubuntu:15.04



ENV DEBIAN_FRONTEND noninteractive

#INSTALL ALL
RUN apt-get update && apt-get install -y  \
       nano \
       php5-fpm \
       php5-mysql \
       nginx



#NGINX CONF
ADD nginx/sites-available/laravel.conf /etc/nginx/sites-available/
RUN rm /etc/nginx/sites-available/default
RUN mv /etc/nginx/sites-available/laravel.conf /etc/nginx/sites-available/default

VOLUME /www


ENTRYPOINT nginx && service php5-fpm start && /bin/bash

CMD ["true"]


EXPOSE 80

docker-compose.yml

version: '2'
services:
  ubuntu:
        build: .
        container_name: ubuntu
        volumes:
            - ~/sph/laravel52:/www/laravel
        ports:
          - "80:80"


推荐答案

事情是你使用选项 -t 运行容器时。

The thing is that you are using the option -t when running your container.

您可以检查是否启用 tty 选项(请参阅参考)在您的docker-compose.yml文件中容器继续运行?

Could you check if enabling the tty option (see reference) in your docker-compose.yml file the container keeps running?

version: '2'
services:
  ubuntu:
        build: .
        container_name: ubuntu
        volumes:
            - ~/sph/laravel52:/www/laravel
        ports:
          - "80:80"
        tty: true

这篇关于Docker-Composer退出代码0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆