Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Containers always exit with code 0 #33

Open
bbergeron0 opened this issue Oct 13, 2020 · 3 comments
Open

Containers always exit with code 0 #33

bbergeron0 opened this issue Oct 13, 2020 · 3 comments

Comments

@bbergeron0
Copy link

Hi, I can't get the container to run. After docker-compose up, it spit out some trace, then exit with code 0.

The traces:

nginx_1     | templating scripts from /etc/nginx/user.conf.d to /etc/nginx/conf.d
nginx_1     | Substituting variables 
nginx_1     |  -> /etc/nginx/user.conf.d/app.conf
nginx_1     | Done with startup
nginx_1     | Run certbot
nginx_1     | ++ parse_domains
nginx_1     | ++ for conf_file in /etc/nginx/conf.d/*.conf*
nginx_1     | ++ sed -n -r -e 's&^\s*ssl_certificate_key\s*\/etc/letsencrypt/live/(.*)/privkey.pem;\s*(#.*)?$&\1&p' /etc/nginx/conf.d/app.conf
nginx_1     | ++ xargs echo
nginx_1     | ++ for conf_file in /etc/nginx/conf.d/*.conf*
nginx_1     | ++ sed -n -r -e 's&^\s*ssl_certificate_key\s*\/etc/letsencrypt/live/(.*)/privkey.pem;\s*(#.*)?$&\1&p' /etc/nginx/conf.d/certbot.conf
nginx_1     | ++ xargs echo
nginx_1     | + for domain in $(parse_domains)
nginx_1     | + is_renewal_required service.domain.com
nginx_1     | + last_renewal_file=/etc/letsencrypt/live/service.domain.com/privkey.pem
nginx_1     | + '[' '!' -e /etc/letsencrypt/live/service.domain.com/privkey.pem ']'
nginx_1     | + one_week_sec=604800
nginx_1     | ++ date -d now +%s
nginx_1     | + now_sec=1602608722
nginx_1     | ++ stat -c %Y /etc/letsencrypt/live/service.domain.com/privkey.pem
nginx_1     | + last_renewal_sec=1602607046
nginx_1     | + last_renewal_delta_sec=1676
nginx_1     | + is_finshed_week_sec=603124
nginx_1     | + '[' 603124 -lt 0 ']'
nginx_1     | + echo 'Not run certbot for service.domain.com; last renewal happened just recently.'
nginx_1     | Not run certbot for service.domain.com; last renewal happened just recently.
nginx_1     | + auto_enable_configs
nginx_1     | + for conf_file in /etc/nginx/conf.d/*.conf*
nginx_1     | + keyfiles_exist /etc/nginx/conf.d/app.conf
nginx_1     | ++ parse_keyfiles /etc/nginx/conf.d/app.conf
nginx_1     | ++ sed -n -e 's&^\s*ssl_certificate_key\s*\(.*\);&\1&p' /etc/nginx/conf.d/app.conf
nginx_1     | + for keyfile in $(parse_keyfiles $1)
nginx_1     | + currentfile=/etc/letsencrypt/live/service.domain.com/privkey.pem
nginx_1     | + '[' '!' -f /etc/letsencrypt/live/service.domain.com/privkey.pem ']'
nginx_1     | + return 0
nginx_1     | + '[' conf = nokey ']'
nginx_1     | + for conf_file in /etc/nginx/conf.d/*.conf*
nginx_1     | + keyfiles_exist /etc/nginx/conf.d/certbot.conf
nginx_1     | ++ parse_keyfiles /etc/nginx/conf.d/certbot.conf
nginx_1     | ++ sed -n -e 's&^\s*ssl_certificate_key\s*\(.*\);&\1&p' /etc/nginx/conf.d/certbot.conf
nginx_1     | + return 0
nginx_1     | + '[' conf = nokey ']'
nginx_1     | + set +x
nginx_1     | /scripts/entrypoint.sh: line 48:    17 Hangup                  nginx -g "daemon off;"
srv_nginx_1 exited with code 0

My setup:

Docker-compose.yml:

version: "3.8"
services:
    nginx:
        image: staticfloat/nginx-certbot
        ports:
            - "80:80/tcp"
            - "443:443/tcp"
        environment:
            CERTBOT_EMAIL: [email protected]
        volumes:
            - "./app.conf:/etc/nginx/user.conf.d/app.conf:ro"
            - "letsencrypt:/etc/letsencrypt"
        links:
            - "http-container"

    http-container:
        # ...

volumes:
    letsencrypt:

app.conf:

server {
    listen 443 ssl;
    server_name service.domain.net;
    ssl_certificate /etc/letsencrypt/live/service.domain.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/service.domain.net/privkey.pem;

    location / {
        proxy_pass http://http-container:8080;
    }
}

✅ No ISP restriction on port 80 or 443
✅ Port 80 and 443 are opened and forwarded correctly
My DNS is NoIP (A DDNS provider)

Everything seems in order, then where's the issue?

(Also is it possible to make the trace less verbose? It seems to print out every line of code it's executing, and I don't need that in my logs.)

Thanks

@muffledMitosis
Copy link

Hi I have the same issue, cant find a solution :`)

@jhagberg
Copy link

Yes same her.

@RY908
Copy link

RY908 commented Mar 4, 2021

I had the same issue.
When stopping the container, running docker-compose down -v instead of docker-compose down worked for me.
It stopped exiting with code 0 when running docker-compose up.
But I don't know if this is the right way to avoid this issue.

staticfloat pushed a commit that referenced this issue Jun 23, 2022
In issue [#33][1] there was a request for having the container add
the configuration files at runtime, instead of having to build from
your own Dockerfile.

I was first sceptical of this, since this would deviate quite a bit
from the original setup of this image, but I think I have found a
method that is sort of backwards compatible while still allowing
people to just mount a local folder and have it work.

This will also allow us to update the config files currently in
nginx_conf.d, and have them propagate to users mounting folders
into the container.

[1]: JonasAlfredsson/docker-nginx-certbot#33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants