Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest image run nginx problems #185

Closed
gatspy opened this issue Jun 15, 2016 · 8 comments
Closed

latest image run nginx problems #185

gatspy opened this issue Jun 15, 2016 · 8 comments
Labels

Comments

@gatspy
Copy link

gatspy commented Jun 15, 2016

Dockfile
FROM gliderlabs/alpine:latest
RUN apk-install bash nginx
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

docker run -ti --rm --name base -P dev-alpine
nginx: [emerg] open() "/run/nginx/nginx.pid" failed (2: No such file or directory)

@alexdglover
Copy link

I'm having the same problem, exact same error message:

nginx: [emerg] open() "/run/nginx/nginx.pid" failed (2: No such file or directory)

Tried moving the "daemon off;" directive into the nginx.conf file as well, no change. Reproduced the same issue by running the container in interactive mode and manually running

nginx

and

nginx -g "daemon off;"

Docker version:

Docker version 1.10.3, build 20f81dd (running on Mac OSX)

Docker file:

FROM alpine
EXPOSE 80
RUN apk update \
    && apk add nginx
COPY nginx.conf /etc/nginx/nginx.conf
RUN mkdir -p /usr/share/nginx/www
COPY run.sh /usr/local/bin/run.sh
RUN chmod +x /usr/local/bin/run.sh
CMD ["/usr/local/bin/run.sh"]

the /usr/local/bin/run.sh script simply updates some HTML/JS assets and then executes 'nginx'

Full disclosure, very new to Alpine. Any help/guidance appreciated.

@zaius
Copy link

zaius commented Jun 28, 2016

It looks like the build of nginx is using /run/nginx/nginx.pid for the default PID location. You can either create /run/nginx, or override the PID location, e.g. nginx -g 'pid /tmp/nginx.pid; daemon off;'

You can check configure options on nginx with -V - e.g.

bash-4.3# nginx -V
nginx version: nginx/1.10.1
built with OpenSSL 1.0.2h  3 May 2016
TLS SNI support enabled
configure arguments: --prefix=/var/lib/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/run/nginx/nginx.pid --lock-path=/run/nginx/nginx.lock --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv6

ecliptik added a commit to Demandbase/docker-nginx-https-redirect that referenced this issue Jul 20, 2016
dhartunian pushed a commit to positiondev/nginx-proxy that referenced this issue Jul 27, 2016
@svenvarkel
Copy link

Add following line to your Dockerfile:

RUN mkdir -p /run/nginx

@andyshinn
Copy link
Contributor

The previous posted answers should be fine for solving this. I think it has enough visibility now that it can be closed and still searched for in the future. Though, maybe the nginx package should be creating this folder...

@klaygomes
Copy link

I know it is closed.. But just a question, how did you know that was necessary to create this directory to fix this issue? Just curious @svenvarkel

@svenvarkel
Copy link

@klaygomes I don't know ... Perhaps it's 20+ years of experience ... :)

@henfj
Copy link

henfj commented May 11, 2017

add the path:
mkdir -p /var/lib/nginx
mkdir -p /var/lib/nginx/tmp

how did say: @klaygomes.

@sasakocic
Copy link

sasakocic commented Jul 25, 2017

Maybe a fresh pair of eyes can answer @klaygomes question how to get to the solution
RUN mkdir -p /run/nginx from /run/nginx/nginx.pid" failed (2: No such file or directory):

  • nginx.pid is created, so ti must be missing folder /run/nginx/
  • when you see the configuration by logging into and typing nginx -V it shows --pid-path=/run/nginx/nginx.pid this folder is indeed needed for process id storing

fijimunkii added a commit to fijimunkii/docker-https-redirect that referenced this issue Jul 26, 2017
MightyNerdEric pushed a commit to MightyNerdEric/alpine-nginx-phpfpm-pgsql that referenced this issue Feb 1, 2019
This is a known problem with newer alpine/nginx. See
gliderlabs/docker-alpine#185.
MightyNerdEric pushed a commit to MightyNerdEric/alpine-nginx-phpfpm-pgsql that referenced this issue Feb 1, 2019
This is a known problem with newer alpine/nginx. See
gliderlabs/docker-alpine#185.
MightyNerdEric pushed a commit to MightyNerdEric/alpine-nginx-phpfpm-pgsql that referenced this issue Feb 1, 2019
This is a known problem with newer alpine/nginx. See
gliderlabs/docker-alpine#185.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants