I am trying to setup an NGINX server and mount a directory to the container. I have a DigitalOcean server running, and want to link my website data into the nginx container.
Part of the docker file is:
webserver:
depends_on:
- wordpress
image: nginx:latest
container_name: webserver
restart: unless-stopped
# Expose port 80 to enable the config options defined nginx.conf
ports:
- "80:80"
- "443:443"
# combiation of named volumes and bind mounts
# bind wordpress app code
# bind nginx config dir on host
# mount certbot certificates and keys for domain
volumes:
- wp_data:/var/www/html
- ~/custom:/etc/nginx/conf.d/custom
- ./nginx-conf:/etc/nginx/conf.d
- certbot-etc:/etc/letsencrypt
networks:
- kgNetwork
command: /bin/bash -c "envsubst < /etc/nginx/conf.d/custom > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
nginx.conf
server {
# Tells ngxinx to listen on port 80
listen 80;
listen [::]:80;
root /usr/share/nginx/html;
index index.html index.htm;
location /
{
try_files $uri $uri/ =404;
}
}
the container starts but I don't see my linked test html file. the log shows: envsubst: error while reading "standard input": Is a directory
I am not quite sure how to understand this. On my server I created in my home folder the subfolder "custom" containing an index.html.
My thought process so far was:
- Create a custom html in the host folder
- Mount the volume via
~/custom:/etc/nginx/conf.d/custom - Run the command:
/bin/bash -c "envsubst < /etc/nginx/conf.d/custom > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"to setup the custom website on nginx.
The nginx container is running but loading the site does not show anything. I am new to docker and tried to debug for 2hrs now but I am clearly missing the point :)
Thanks Sebastian