运行docker nginx容器失败,没有警告或错误
我正在尝试运行一个NGINX容器,从外观上看,它启动时没有问题,但当尝试访问任何页面时,它假设是宿主,我“无法连接”,它不会给出通常的NGINX欢迎或NGINX错误 启动时,我会得到以下日志:运行docker nginx容器失败,没有警告或错误,docker,nginx,fedora-coreos,Docker,Nginx,Fedora Coreos,我正在尝试运行一个NGINX容器,从外观上看,它启动时没有问题,但当尝试访问任何页面时,它假设是宿主,我“无法连接”,它不会给出通常的NGINX欢迎或NGINX错误 启动时,我会得到以下日志: $ sudo docker-compose up Starting production_nginx ... done Attaching to production_nginx production_nginx | /docker-entrypoint.sh: /docker-entrypoint.d/
$ sudo docker-compose up
Starting production_nginx ... done
Attaching to production_nginx
production_nginx | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
production_nginx | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
production_nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
production_nginx | 10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf is not a file or does not exist, exiting
production_nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
production_nginx | /docker-entrypoint.sh: Configuration complete; ready for start up
我的docker-compose.yml如下所示:
version: "3.7"
services:
nginx:
image: nginx:latest
container_name: production_nginx
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /etc/letsencrypt/:/etc/letsencrypt/
- /opt/nginx_cache/:/opt/nginx_cache/
- /var/home/core/docker/nginx/dhparam.pem:/etc/nginx/dhparam.pem
- /var/home/core/docker/nginx/conf.d/:/etc/nginx/conf.d/
- /var/home/core/docker/files/:/var/home/core/docker/files/
- /var/home/core/docker/nginx/nginx.conf:/etc/nginx/nginx.conf
- /var/log/nginx/:/var/log/nginx/:Z
networks:
- proxynet
- abnet
- dsnet
networks:
proxynet:
name: source_network
abnet:
name: one_network
dsnet:
name: two_network
我已经进入了NGINX容器的外壳并测试了所有通过测试的配置文件
还有什么会导致这个问题
编辑添加nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
client_max_body_size 50M;
client_body_buffer_size 50M;
ssl_session_timeout 10m;
ssl_ecdh_curve secp384r1;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_stapling on;
ssl_stapling_verify on;
proxy_cache_path /opt/nginx_cache levels=1:2 keys_zone=nginx_cache:60m max_size=300m inactive=24h;
proxy_cache_key "$scheme$request_method$host$request_uri";
proxy_cache_methods GET HEAD;
}
你能分享一下nginx.conf吗?例如,如果
proxy\u pass
中使用的上游服务器不可用,Nginx将停止。我不熟悉Nginx的内部结构,但请确保Nginx不会作为守护进程启动。如果它作为守护进程启动,容器的主进程将退出并导致容器被终止。@trallnag我已经添加了nginx。conf@ashu如何知道nginx容器是否作为deamon运行?@只需在配置中指定其用户,但为了验证,您可以尝试显式指定该标志。好的,nginx有一个cmd标志来控制它。