Host OS: macOS Mojave
I'm building a simple Docker container for Nginx. nginx will start correctly in interactive mode, but fails silently when invoked by a RUN command in a Dockerfile.
Dockerfile:
FROM ubuntu:18.04
RUN apt-get update && \ apt-get -y install nginx net-tools
WORKDIR /etc/nginx
COPY nginx.conf ./nginx.conf
RUN service nginx start
CMD /bin/bash
Kickoff script with replication of issue:
$ docker build -t blog_nginx . && docker run -it blog_nginx
Sending build context to Docker daemon 62.46kB
Step 1/6 : FROM ubuntu:18.04
---> 94e814e2efa8
Step 2/6 : RUN apt-get update && apt-get -y install nginx net-tools
---> Using cache
---> 18300d884828
Step 3/6 : WORKDIR /etc/nginx
---> Using cache
---> 22da684cd328
Step 4/6 : COPY nginx.conf ./nginx.conf
---> Using cache
---> 76624c016191
Step 5/6 : RUN service nginx start
---> Using cache
---> 0987fab7a011
Step 6/6 : CMD /bin/bash
---> Using cache
---> 7bdce4aa6802
Successfully built 7bdce4aa6802
Successfully tagged blog_nginx:latest
root@846f4e47e369:/etc/nginx# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 01:15 pts/0 00:00:00 /bin/sh -c /bin/bash
root 6 1 0 01:15 pts/0 00:00:00 /bin/bash
root 11 6 0 01:15 pts/0 00:00:00 ps -ef
root@846f4e47e369:/etc/nginx# service nginx start
* Starting nginx nginx
root@846f4e47e369:/etc/nginx# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 01:15 pts/0 00:00:00 /bin/sh -c /bin/bash
root 6 1 0 01:15 pts/0 00:00:00 /bin/bash
root 31 1 0 01:15 ? 00:00:00 nginx: master process /usr/sbin/nginx
nobody 32 31 0 01:15 ? 00:00:00 nginx: worker process
root 34 6 0 01:16 pts/0 00:00:00 ps -ef