Reputation: 21282
I have an nginx service in my docker-compose. I'm trying to use this to obtain my first ssl cert from lets encrypt. It's not working and I cannot seem to exec into the container to check the conf settings.
I'm using envsubt and I suspect this is my issue, but since I cannot get into the container I cannot check. My set up:
version: '3'
services:
nginx:
image: nginx:latest
restart: unless-stopped
volumes:
- ./templates:/etc/nginx/templates
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
- ./entry-scripts/40-reload.sh:/docker-entrypoint.d/40-reload.sh
ports:
- "80:80"
- "443:443"
networks:
- collabora
env_file: .env
File 40-reload.sh
# reload nginx config every 60 seconds in case certs get updated
while :; do
sleep 60
echo reloading
nginx -s reload
done &
nginx -g 'daemon off;'
File .templates/default.conf.template
which I place in /etc/nginx/templates
:
ssl_certificate /etc/letsencrypt/live/${COLLABORA_DOMAIN}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${COLLABORA_DOMAIN}/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
server_tokens off;
server {
listen 80;
server_name www.${COLLABORA_DOMAIN} ${COLLABORA_DOMAIN};
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
return 301 https://${COLLABORA_DOMAIN}$request_uri;
}
server {
listen 443 ssl;
server_name www.${COLLABORA_DOMAIN} ${COLLABORA_DOMAIN}
return 301 $scheme://${COLLABORA_DOMAIN}$request_uri;
}
server {
listen 443 ssl;
server_name ${COLLABORA_DOMAIN};
location / {
proxy_pass http://collabora:9980;
access_log off;
proxy_set_header Host $host;
}
# static files
location ^~ /loleaflet {
proxy_pass http://collabora:9980;
proxy_set_header Host $http_host;
}
# WOPI discovery URL
location ^~ /hosting/discovery {
proxy_pass http://collabora:9980;
proxy_set_header Host $http_host;
}
# Capabilities
location ^~ /hosting/capabilities {
proxy_pass http://collabora:9980;
proxy_set_header Host $http_host;
}
# main websocket
location ~ ^/lool/(.*)/ws$ {
proxy_pass http://collabora:9980;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_read_timeout 36000s;
}
# download, presentation and image upload
location ~ ^/lool {
proxy_pass http://collabora:9980;
proxy_set_header Host $http_host;
}
# Admin Console websocket
location ^~ /lool/adminws {
proxy_pass http://collabora:9980;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_read_timeout 36000s;
}
}
When I run with docker-compose up -d nginx
I can see:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
08e8279e91a0 nginx:latest "/docker-entrypoint.…" 17 minutes ago Restarting (1) 19 seconds ago collabora_nginx_1
But I cannot get inside to see the conf settings:
docker-compose exec nginx /bin/bash
Error response from daemon: Container 08e8279e91a081da976d1ea3df7dfe33974744959fe8441eca365ffabc343d53 is restarting, wait until the container is running
I'd like to get inside the container and run nginx -T
to verify my conf variables.
How can I get into the container to see the conf variables?
Upvotes: 1
Views: 3033
Reputation: 3611
Try to restart the container and check the status of the container
docker restart <your_container_name>
If the status is running then login to the container using exec
command
docker exec -it <your_container_name/id> bash
Upvotes: 1