Docker Hub官方Nginx镜像配置问题
PHPz
PHPz 2017-04-24 09:14:02
0
2
1125

Docker Hub官方Nginx镜像文档
https://hub.docker.com/_/nginx/
跟着文档说明进行配置,有些问题不知道什么意思,
原文引用:

using environment variables in nginx configuration

Out-of-the-box, Nginx doesn't support using environment variables inside most configuration blocks. But envsubst may be used as a workaround if you need to generate your nginx configuration dynamically before nginx starts.

Here is an example using docker-compose.yml:

image: nginx
  volumes:
   - ./mysite.template:/etc/nginx/conf.d/mysite.template
  ports:
   - "8080:80"
  environment:
   - NGINX_HOST=foobar.com
   - NGINX_PORT=80
  command: 
        /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf    
        &&    
        nginx -g 'daemon off;'"

The mysite.template file may then contain variable references like this :

listen ${NGINX_PORT};

问题:
在代码部分最后一行,也就是command:那一行,
1、envsubst作用是什么?
2、daemon off;作用是什么?
3、command:命令本身表示什么意思?什么时候执行后面的命令?

PHPz
PHPz

学习是最好的投资!

모든 응답(2)
小葫芦

envsubst는 아마도 환경 변수를 조작하는 데 사용되었을 것입니다. 자세한 내용은 명령 설명을 참조하세요

daemon off: nginx의 매개변수로 백그라운드에서 시작되지 않음을 나타냅니다.
command는 docker run nginx /bin/sh 에서 이미지 이름 nginx 뒤의 /bin/sh 부분으로 어떤 명령이든 실행할 수 있습니다. .
다른 글에 올리신 것 같아요

PHPzhong

/bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf
교체 구성 파일
nginx - g 'daemon off;'" 정답 위층
명령: 컨테이너가 실행된 후 실행될 명령은 docker run 문의 명령으로 재정의될 수 있습니다.

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!