linuxserver / docker-nginx

GNU General Public License v3.0
145 stars 44 forks source link

Docker image fails to start #54

Closed gsacre closed 4 years ago

gsacre commented 4 years ago

linuxserver.io


Expected Behavior

Latest nginx docker image (image ID: e70f8c94d769) starts using docker-compose.

Current Behavior

When starting the image with docker-copose, the container never runs (it directly exits, only visible using docker ps -a).

Steps to Reproduce

  1. Create a docker-compose file with the below configuration
  2. run docker-compose -f <your-docker-compose-file> up -d

I don't know if this would be relevant but I created a Swarm with 2 nodes and running docker-compose on one of the nodes before deploying the service. The service has never been deployed as nginx is currently failing.

Environment

OS: Ubuntu 18.04 server CPU architecture: x86_64 How docker service was installed: Official documentation from docker website Docker version: Docker version 19.03.5, build 633a0ea838 docker-compose version: docker-compose version 1.25.0, build 0a186604

Command used to create docker container

docker-compose -f test.yml up -d

test.yml docker-compose file:

version: '3.7'
networks:
    cluster:
        driver: bridge    
services:
    nginx:
        image: linuxserver/nginx
        entrypoint: nginx
        container_name: nginx
        ports:
            - 80:80
        networks:
            cluster:
                aliases:
                    - nginx

Docker logs

nginx: [alert] detected a LuaJIT version which is not OpenResty's; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty's LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)
nginx: [error] lua_load_resty_core failed to load the resty.core module from https://github.com/openresty/lua-resty-core; ensure you are using an OpenResty release from https://openresty.org/en/download.html (rc: 2, reason: module 'resty.core' not found:
    no field package.preload['resty.core']
    no file './resty/core.lua'
    no file '/usr/share/luajit-2.1.0-beta3/resty/core.lua'
    no file '/usr/local/share/lua/5.1/resty/core.lua'
    no file '/usr/local/share/lua/5.1/resty/core/init.lua'
    no file '/usr/share/lua/5.1/resty/core.lua'
    no file '/usr/share/lua/5.1/resty/core/init.lua'
    no file '/usr/share/lua/common/resty/core.lua'
    no file '/usr/share/lua/common/resty/core/init.lua'
    no file './resty/core.so'
    no file '/usr/local/lib/lua/5.1/resty/core.so'
    no file '/usr/lib/lua/5.1/resty/core.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
    no file './resty.so'
    no file '/usr/local/lib/lua/5.1/resty.so'
    no file '/usr/lib/lua/5.1/resty.so'
    no file '/usr/local/lib/lua/5.1/loadall.so')
nginx: [emerg] open() "/run/nginx/nginx.pid" failed (2: No such file or directory)
aptalca commented 4 years ago

Remove entrypoint

gsacre commented 4 years ago

@aptalca Thank you! It worked, I wasn't paying attention that it would change the starting behaviour of the container...

gurumark commented 4 years ago

I get the same error: docker run -d \ --name code \ --restart=always \ -e PUID=1000 \ -e PGID=1000 \ -e TZ=America/New_York \ linuxserver/nginx

tobbenb commented 4 years ago

Which error? Please supply enough information for us so we can see what is the issue. The issue of then OP was solved, so probably better to open your own issue. If you only get the Lua errors, then that is normal.

gurumark commented 4 years ago

I get the exact same error as @gsacre


nginx: [alert] detected a LuaJIT version which is not OpenResty's; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty's LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html) nginx: [error] lua_load_resty_core failed to load the resty.core module from https://github.com/openresty/lua-resty-core; ensure you are using an OpenResty release from https://openresty.org/en/download.html (rc: 2, reason: module 'resty.core' not found: no field package.preload['resty.core'] no file './resty/core.lua' no file '/usr/share/luajit-2.1.0-beta3/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core/init.lua' no file '/usr/share/lua/5.1/resty/core.lua' no file '/usr/share/lua/5.1/resty/core/init.lua' no file '/usr/share/lua/common/resty/core.lua' no file '/usr/share/lua/common/resty/core/init.lua' no file './resty/core.so' no file '/usr/local/lib/lua/5.1/resty/core.so' no file '/usr/lib/lua/5.1/resty/core.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file './resty.so' no file '/usr/local/lib/lua/5.1/resty.so' no file '/usr/lib/lua/5.1/resty.so' no file '/usr/local/lib/lua/5.1/loadall.so') nginx: [emerg] open() "/run/nginx/nginx.pid" failed (2: No such file or directory)


then example.com/index.html goes into permanent redirect.

tobbenb commented 4 years ago

Did you try aptalca's suggestion?

gurumark commented 4 years ago

There is no entry point below: docker run -d --name code --restart=always -e PUID=1000 -e PGID=1000 -e TZ=America/New_York linuxserver/nginx


If you run it, you will get the same.

thelamer commented 4 years ago

@gurumark you did not forward a port or even mount any volumes, when I run your exact command I am able to grab the web page just fine though:

docker run -d \
> --name code \
> --restart=always \
> -e PUID=1000 \
> -e PGID=1000 \
> -e TZ=America/New_York \
> linuxserver/nginx
$ docker exec -it code bash
root@2c46a0d9cc3d:/# curl localhost
    <html>
        <head>
            <title>Welcome to our server</title>
            <style>
            body{
                font-family: Helvetica, Arial, sans-serif;
            }
            .message{
                width:330px;
                padding:20px 40px;
                margin:0 auto;
                background-color:#f9f9f9;
                border:1px solid #ddd;
            }
            center{
                margin:40px 0;
            }
            h1{
                font-size: 18px;
                line-height: 26px;
            }
            p{
                font-size: 12px;
            }
            </style>
        </head>
        <body>
            <div class="message">
                <h1>Welcome to our server</h1>
                <p>The website is currently being setup under this address.</p>
                <p>For help and support, please contact: <a href="me@example.com">me@example.com</a></p>
            </div>
        </body>
    </html>

A necro github issue is literally the worst place for support. Please hop on our Discord or forums to continue troubleshooting.

And again the Lua error can be ignored.

gurumark commented 4 years ago

@thelamer I am running this behind a proxy, I don't need to publish a port. You're doing curl localhost that's why it's working for you..

tobbenb commented 4 years ago

We are not seeing the same issue as you are locally, so please either open a new issue and supply all info we ask you to supply or go to our forum or discord to get support. Supplying only bits and pieces is not helpful.