背景
docker-compose up -d 發(fā)現(xiàn)容器啟動后又停止
關(guān)鍵配置
tty: true
模擬一個偽終端,阻止容器退出
docker-compose.yml
[root@test centos]# cat docker-compose.yml
version: "3"
services:
centos:
image: centos:7.5.1804
build:
context: /ROOT/docker/dockerfile
dockerfile: centos
volumes:
- "/ROOT:/ROOT"
container_name: web-server
restart: always
hostname: web-server
tty: true