Use proxy_pass of nginx to container by certbot

  certbot, containers, docker, https, nginx

I try to give my application(pgadmin) https certificate by using certbot and nginx.

My application is created by docker, so it’s a container.

The nginx and certbot are installed directly in the original environment.

sudo apt-get install nginx certbot python3-cerbot-nginx -y

My application is created by docker.

sudo docker create -p 5001:80 -e [email protected] -e PGADMIN_DEFAULT_PASSWORD=mypassword --name PSQLA dpage/pgadmin4
sudo docker start PSQLA

The pgadmin.conf in the /etc/nginx/conf.d/ folder.

  listen 80;
    location / {
      proxy_pass http://localhost:5001;

Get certbot https certificate with certbot command but get the error.

enter image description here

When I create other application without docker, the certbot is work successfully.
But for this case, it not work.
How to solve this problem?

Source: Docker Questions