Dockerfile nginx, container is not running

Hello,

it is my first step, please don’t worry.

I have a dockerfile

FROM debian:jessie
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        wget \
        curl \
        bzip2 \
        locales \
	nano \
        unzip \
	nginx \
        php5 \
        php5-cli \
        php5-curl \
	php5-fpm \
        php5-gd \
        php5-mcrypt \
        php5-mysql \
	php5-ldap \
	mc \
    && apt-get autoremove -y \
    && apt-get clean all \
    && rm -rf /var/lib/apt/lists/*

ADD start.sh /start.sh
RUN chmod +x /start.sh

EXPOSE 80

CMD ["/start.sh"]

then I have my start.sh

!/bin/bash
echo "--- starting nginx ---"
nginx

after then
docker build . -t foo
and then
docker run --name nginxcontainer -d -p 7777:80 foo

the container is not starting.

what is wrong?

Hi,

Can you start the container using:

docker run --name nginxcontainer -p 7777:80 foo

(without the -d option) and see what the log is telling you?

My guess at this moment is that your nginx should run in foreground and there’s some error in your start.sh. If you just want to test, change your start.sh to:

#!/bin/bash
echo "--- starting nginx ---"
/usr/sbin/nignx -g "daemon off;"

now it works with -d and the new start.sh from your post.

i had think that “nginx” is enough…
mhmm

Do

docker run -d --name nginxcontainer -p 7777:80 foo

Will detatch your terminal.

Nginx will always have to run foreground (daemon off) in container. This can be done via the -g "daemon off; " or add daemon off to your Nginx config.

Hello,
In my compute engine I have such a computer and docker setup alone
after docker pull nginx
docker run nginx and other run modes do not have the idea what the problem might be?

Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:10:01 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm

Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:08:31 2018
OS/Arch: linux/amd64
Experimental: false