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

Running init-letsencrypt inside a docker container #97

Open
FynnHunt opened this issue Nov 12, 2020 · 3 comments
Open

Running init-letsencrypt inside a docker container #97

FynnHunt opened this issue Nov 12, 2020 · 3 comments

Comments

@FynnHunt
Copy link

FynnHunt commented Nov 12, 2020

I am trying to run init-letsencrypt inside of a docker container which I use to launch and maintain other docker containers on my host (by volume mounting the docker.sock). This is the docker-compose setup of the container I am trying to run init-letsencrypt inside of -

`version: "3"
services:
...
  pod:
    image: ...
    container_name: ...
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/ubuntu/mothership-pod-config/env.list:/home/ubuntu/mothership-pod-config/env.list
      - /home/ubuntu/mothership-pod-config/nginx:/nginx
      - /etc/letsencrypt:/etc/letsencrypt
      - /var/www/certbot:/var/www/certbot
    ports:
      - "3000:3000"`

The whole nginx-certbot setup is inside my /nginx/ folder in the container, this is where the script is run from.

My assumption here is that by mounting the docker.sock and having access over docker running on the host means that when running docker-compose inside the container the commands will be sent through to the host. I think I have volume mounted the neccessary folders in to the container but I might be missing something?

The problem I am seeing when running init-letsencrypt.sh inside the container is from certbot -

### Creating dummy certificate for ...
Creating network "nginx_backbone" with driver "bridge"
Creating network "nginx_default" with the default driver
Creating nginx_certbot_run ... done
Generating a RSA private key
..........................................................................................................................................++++
................................................++++
writing new private key to '/etc/letsencrypt/live/.../privkey.pem'
req: Can't open "/etc/letsencrypt/live/.../privkey.pem" for writing, No such file or directory

### Starting nginx ...
Creating nginx_nginx_1 ... done

### Deleting dummy certificate for ...
Creating nginx_certbot_run ... done

### Requesting Let's Encrypt certificate for ...
Creating nginx_certbot_run ... done
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for ...
http-01 challenge for ...
Using the webroot path /var/www/certbot for all unmatched domains.
Waiting for verification...
Challenge failed for domain ...
Challenge failed for domain ...
http-01 challenge for ...
http-01 challenge for ...
Cleaning up challenges
Some challenges have failed.

Note: I have replaced my domain and other non relevant information with "...".

I might be missing something here but it looks like certbot is failing to write to /etc/letsencrypt/live ? Is this a permissions problem as I am attempting to run the script from within a container? Any help will be greatly appreciated!

Additional note: I tried checking the certbot log file in /var/log/letsencrypt/letsencrypt.log and it did not exist.

@hajo62
Copy link

hajo62 commented Jan 2, 2021

Additional note: I tried checking the certbot log file in /var/log/letsencrypt/letsencrypt.log and it did not exist.
I also can't find a log, which is a problem when trying debug ;(

@paasshme
Copy link

paasshme commented Dec 4, 2021

Did you managed to fix it ?

@Vivekgupta98
Copy link

Make sure to run the script with staging=1 atleast once to create all required structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants