# Trouble using certbot with nginx on docker

**URL:** <https://community.letsencrypt.org/t/trouble-using-certbot-with-nginx-on-docker/59061>\
**Category:** Help\
**Created:** [April 10, 2018, 3:15am UTC](https://community.letsencrypt.org/t/trouble-using-certbot-with-nginx-on-docker/59061 "2018-04-10T03:15:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saipathuri](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/saipathuri/32/22359_2.png) [@saipathuri](https://community.letsencrypt.org/u/saipathuri)\
**Post date:** [April 10, 2018, 3:15am UTC](https://community.letsencrypt.org/t/trouble-using-certbot-with-nginx-on-docker/59061/1 "2018-04-10T03:15:41Z")

</div>

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. [crt.sh | example.com](https://crt.sh/?q=example.com)), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

**My domain is:** [cpc.saipathuri.me](http://cpc.saipathuri.me)

**I ran this command** :

> docker run -it --rm   
> -v certs:/etc/letsencrypt   
> -v certs-data:/data/letsencrypt   
> deliverous/certbot   
> certonly   
> --staging   
> --webroot --webroot-path=/data/letsencrypt   
> -d [cpc.saipathuri.me](http://cpc.saipathuri.me)

which is `certbot certonly --staging --webroot --webroot-path=/data/letsencrypt -d cpc.saipathuri.me`

**It produced this output** :

> ```
> Saving debug log to /var/log/letsencrypt/letsencrypt.log
> Plugins selected: Authenticator webroot, Installer None
> Obtaining a new certificate
> /usr/local/lib/python2.7/site-packages/josepy/jwa.py:107: CryptographyDeprecationWarning: signer and verifier have been deprecated. Please use sign and verify instead.
> signer = key.signer(self.padding, self.hash)
> Performing the following challenges:
> http-01 challenge for cpc.saipathuri.me
> Using the webroot path /data/letsencrypt for all unmatched domains.
> Waiting for verification...
> Cleaning up challenges
> Failed authorization procedure. cpc.saipathuri.me (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://cpc.saipathuri.me/.well-known/acme-challenge/ICJP8LP-i23YkwaLUIVC272cRJTsdToJLDtc2fUGoJE: "<html>
> <head><title>404 Not Found</title></head>
> <body bgcolor="white">
> <center><h1>404 Not Found</h1></center>
> <hr><center>"
> 
> IMPORTANT NOTES:
> - The following errors were reported by the server:
> 
> Domain: cpc.saipathuri.me
> Type: unauthorized
> Detail: Invalid response from
> http://cpc.saipathuri.me/.well-known/acme-challenge/ICJP8LP-i23YkwaLUIVC272cRJTsdToJLDtc2fUGoJE:
> "<html>
> <head><title>404 Not Found</title></head>
> <body bgcolor="white">
> <center><h1>404 Not Found</h1></center>
> <hr><center>"
> 
> To fix these errors, please make sure that your domain name was
> entered correctly and the DNS A/AAAA record(s) for that domain
> contain(s) the right IP address.
> 
> ```

**My web server is (include version):** nginx

**The operating system my web server runs on is (include version)**: docker

**My hosting provider, if applicable, is** : AWS EC2

**I can login to a root shell on my machine (yes or no, or I don't know)**: yes

**I'm using a control panel to manage my site (no, or provide the name and version of the control panel)**: no

I am able to access the /.well-known/acme-challenge directory ([http://cpc.saipathuri.me/.well-known/acme-challenge/test.txt](http://cpc.saipathuri.me/.well-known/acme-challenge/test.txt)) with a test file, but certbot keeps failing. Please help!

---

<div class="post-metadata">

**Author:** ![schoen](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/schoen/32/79_2.png) [@schoen](https://community.letsencrypt.org/u/schoen)\
**Post date:** [April 10, 2018, 3:32am UTC](https://community.letsencrypt.org/t/trouble-using-certbot-with-nginx-on-docker/59061/2 "2018-04-10T03:32:02Z")

</div>

Hi @saipathuri,

Is this file `test.txt` located in `/data/letsencrypt/.well-known/acme-challenge`?

---

<div class="post-metadata">

**Author:** ![saipathuri](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/saipathuri/32/22359_2.png) [@saipathuri](https://community.letsencrypt.org/u/saipathuri)\
**Post date:** [April 10, 2018, 4:24am UTC](https://community.letsencrypt.org/t/trouble-using-certbot-with-nginx-on-docker/59061/3 "2018-04-10T04:24:58Z")

</div>

Hi @schoen,

Yes, it is.

---

<div class="post-metadata">

**Author:** ![saipathuri](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/saipathuri/32/22359_2.png) [@saipathuri](https://community.letsencrypt.org/u/saipathuri)\
**Post date:** [April 10, 2018, 7:31pm UTC](https://community.letsencrypt.org/t/trouble-using-certbot-with-nginx-on-docker/59061/4 "2018-04-10T19:31:16Z")

</div>

After hours and hours of debugging, I figued out what the issue was. Turns out docker prepends volume names for volumes in certain situations (not sure when, I don't know enough about Docker), so the volumes created by running

> docker-compose up -d

with my docker-compose file created volumes named

> mysite\_certs

and

> mysite\_certs-data

instead of

> certs

and

> certs-data

So I modified

> docker run -it --rm  
> -v certs:/etc/letsencrypt  
> -v certs-data:/data/letsencrypt  
> deliverous/certbot  
> certonly  
> –staging  
> –webroot --webroot-path=/data/letsencrypt  
> -d [cpc.saipathuri.me](http://cpc.saipathuri.me)

to be

> docker run -it --rm  
> -v **mysite\_certs** :/etc/letsencrypt  
> -v **mysite\_certs-data** :/data/letsencrypt  
> deliverous/certbot  
> certonly  
> –staging  
> –webroot --webroot-path=/data/letsencrypt  
> -d [cpc.saipathuri.me](http://cpc.saipathuri.me)

and that fixed the issue!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)\
**Post date:** [May 10, 2018, 7:31pm UTC](https://community.letsencrypt.org/t/trouble-using-certbot-with-nginx-on-docker/59061/5 "2018-05-10T19:31:41Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
