Why docker container exits immediately

后端 未结 15 2358
温柔的废话
温柔的废话 2020-11-22 13:42

I run a container in the background using

 docker run -d --name hadoop h_Service

it exits quickly. But if I run in the foreground, it works

15条回答
  •  [愿得一人]
    2020-11-22 14:24

    Add this to the end of Dockerfile:

    CMD tail -f /dev/null
    

    Sample Docker file:

    FROM ubuntu:16.04
    
    # other commands
    
    CMD tail -f /dev/null
    

    Reference

提交回复
热议问题