0

I had a dockerfile which tried to install nginx like following:

Dockerfile

FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y expect
RUN apt-get -y install software-properties-common 
RUN apt-add-repository ppa:ondrej/php
RUN apt-get -y install php7.1 php7.1-fpm 
RUN apt-get install php7.1-mysql
RUN apt-get -y install nginx

For some reason, I tried to run dockfile inside docker-compose:

version: '3'

services:
   web:
     build: 
       context: .
       dockerfile: Dockerfile
     ports:
       - "3011:80"
     command: nginx

After I run docker-compose up, I access 127.0.0.1:3011, but nginx is not running.

Seems like nginx haven't been start. Am I doing wrong at this line?

command: nginx
jimmy
  • 1,549
  • 5
  • 21
  • 38
  • Possible duplicate of [How to run Nginx within a Docker container without halting?](https://stackoverflow.com/questions/18861300/how-to-run-nginx-within-a-docker-container-without-halting) – David Maze Sep 11 '18 at 09:44
  • Add `RUN echo "daemon off;" >> /etc/nginx/nginx.conf` this in your dockerfile. – Mahattam Sep 11 '18 at 11:39
  • @Mahattam Hello, even thought I tried RUN echo "daemon off;" >> /etc/nginx/nginx.conf or CMD ["nginx", "-g", "daemon off;"] it still can't work, I just add the command line at the bottom of dockerfile, is that right? – jimmy Sep 12 '18 at 03:27
  • @DavidMaze I add the command at the bottom of dockerfile, but still can't work, anything I missing? – jimmy Sep 12 '18 at 03:29
  • The `command:` in the `docker-compose.yml` overrides the CMD in the `Dockerfile`, if you didn't change (or remove) it. – David Maze Sep 12 '18 at 09:41

0 Answers0