我有一些在Python 2.7中运行良好的代码.
Python 2.7.3 (default, Jan 2 2013, 13:56:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import stdout
>>> foo = 'Bar'
>>> numb = 10
>>> stdout.write('{} {}\n'.format(numb, foo))
10 Bar
>>>
Run Code Online (Sandbox Code Playgroud)
但是在2.6中我得到了一个ValueError异常.
Python 2.6.8 (unknown, Jan 26 2013, 14:35:25)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import stdout
>>> foo = 'Bar'
>>> numb = 10
>>> stdout.write('{} {}\n'.format(numb, foo)) …Run Code Online (Sandbox Code Playgroud) python string-formatting backwards-compatibility python-2.6 python-2.7
如果你有一个if语句,其中评估了几个变量或函数,它们的评估顺序是什么?
if foo > 5 or bar > 6:
print 'foobar'
Run Code Online (Sandbox Code Playgroud)
在这个特定的情况下,将foo与5进行评估然后对6进行评估(从左到右)还是从右到左进行评估?我假设a or和and以相同的顺序进行评估.
我意识到这个问题写得有多糟糕,所以我重写了整个问题并给出了解决方案。
TLDR:我想要一个关于如何让 docker certbot/certbot 容器检索到的 LetsEncrypt 证书和密钥可供 nginx:latest 容器读取的解决方案或建议。
它不可读的原因是证书存储在一个文件夹中,通常是 /etc/letsencrypt/archive/domain/certificates,并且文件夹存档的所有者设置为 root,组设置为 root,模式为 0700。密钥的所有者也设置为 root,组设置为 root,模式为 0600。
nginx 容器将 pid 0 设置为 nginx 主进程并由 root 运行,但它会生成一个需要读取证书和密钥的工作进程。该工作进程由非特权用户拥有。
DOCKER-COMPOSE 配置
---
version: '3'
services:
nginx:
container_name: nginx
image: nginx:latest
ports:
- 80:80
- 443:443
volumes:
- ./data/nginx/conf:/etc/nginx/conf.d
# The volume under is to provide the DHPARAM file.
- ./data/nginx/tls:/etc/pki/tls
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
# This reloads the certificates every 24h as long as the container is running
command: "/bin/sh -c 'while :; …Run Code Online (Sandbox Code Playgroud)