docker容器启动时,就自动退出了,求解决方案

图片说明

这个是Dockerfile

FROM daocloud.io/library/nginx:1.13.5-alpine
RUN apk update $$ apk upgrade
RUN apk add --no-cache bash curl ipvsadm iproute2 openrc keepalived
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD ["/entrypoint.sh","/bin/bash"]

这个是entrypoint.sh

#!/bin/sh

#/usr/sbin/keepalvined -n -l -D -f /etc/keepalived/keepalived.conf --dont-fork --log-console &
/usr/sbin/keepalived -D -f /etc/keepalived/keepalived.conf 


nginx -g "daemon off;" 

docker-compose

version: "3.1"
services:
  nginx_master:
    build:
      context: ./
      dockerfile: ./Dockerfile
    ports:
      - 8081:80
    volumes:
      - ./index-master.html:/usr/share/nginx/html/index.html
      - ./favicon.ico:/usr/share/nginx/html/favicon.ico
      - ./keepalived-master.conf:/etc/keepalived/keepalived.conf
    networks:
      static-network:
        ipv4_address: 172.20.128.2
    cap_add:
      - NET_ADMIN
  nginx_slave:
    build:
      context: ./
      dockerfile: ./Dockerfile
    ports:
      - 8082:80
    volumes:
      - ./index-slave.html:/usr/share/nginx/html/index.html
      - ./favicon.ico:/usr/share/nginx/html/favicon.ico
      - ./keepalived-slave.conf:/etc/keepalived/keepalived.conf
    networks:
      static-network:
        ipv4_address: 172.20.128.3
    cap_add:
      - NET_ADMIN
  proxy:
    image: daocloud.io/library/haproxy:1.7-alpine
    ports:
      - 80:6301
    volumes:
      - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
    networks:
      - static-network

networks:
  static-network:
    ipam:
      config:
        - subnet: 172.20.0.0/16

不知道哪里的问题 网上找了说要在Dockerfile或者.sh里加一个死循环让他前台运行,但具体还是不知道怎么解决,有没有大佬指导一下

https://blog.csdn.net/do_it_/article/details/80014321