大网数据广告活动
服务器运维问答

Using Let's Encrypt inside Docker's official Wordpress container

· 52CE 我爱测

I'm trying to get Let's Encrypt inside the official Docker Wordpress container. Setup the environment $ cat docker-compose.yml wordpress: hostname: some.fqdn.com image: wordpress links: - db:mysql ports: - 80:80 - 443:443 db: ima…

问题原文

原帖链接 · vpetersson · CC BY-SA 3.0

I'm trying to get Let's Encrypt inside the official Docker Wordpress container.

Setup the environment

$ cat docker-compose.yml
wordpress:
  hostname: some.fqdn.com
  image: wordpress
  links:
    - db:mysql
  ports:
    - 80:80
    - 443:443

db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: example

$ docker-compose -f docker-compose.yml up -d
$ docker exec -ti root_wordpress_1 bash

Install Let's Encrypt

$ apt-get update && apt-get install -y git-core
[...]
$ cd /usr/local
$ git clone https://github.com/letsencrypt/letsencrypt
[...] 
$ cd letsencrypt/
$ ./letsencrypt-auto --apache
Checking for new version...
Requesting root privileges to run letsencrypt...
   /root/.local/share/letsencrypt/bin/letsencrypt --apache
An unexpected error occurred:
PythonDialogBug
Please see the logfiles in /var/log/letsencrypt for more details.

More logs

$ cat /var/log/letsencrypt/letsencrypt.log
2016-03-04 15:28:41,551:DEBUG:letsencrypt.cli:Root logging level set at 30
2016-03-04 15:28:41,553:INFO:letsencrypt.cli:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2016-03-04 15:28:41,554:DEBUG:letsencrypt.cli:letsencrypt version: 0.4.2
2016-03-04 15:28:41,554:DEBUG:letsencrypt.cli:Arguments: ['--apache']
2016-03-04 15:28:41,555:DEBUG:letsencrypt.cli:Discovered plugins: PluginsRegistry(PluginEntryPoint#apache,PluginEntryPoint#webroot,PluginEntryPoint#null,PluginEntryPoint#manual,PluginEntryPoint#standalone)
2016-03-04 15:28:41,559:DEBUG:letsencrypt.cli:Requested authenticator apache and installer apache
2016-03-04 15:28:42,166:DEBUG:letsencrypt.display.ops:Single candidate plugin: * apache
Description: Apache Web Server - Alpha
Interfaces: IAuthenticator, IInstaller, IPlugin
Entry point: apache = letsencrypt_apache.configurator:ApacheConfigurator
Initialized: <letsencrypt_apache.configurator.ApacheConfigurator object at 0x7fd05eb85310>
Prep: True
2016-03-04 15:28:42,168:DEBUG:letsencrypt.cli:Selected authenticator <letsencrypt_apache.configurator.ApacheConfigurator object at 0x7fd05eb85310> and installer <letsencrypt_apache.configurator.ApacheConfigurator object at 0x7fd05eb85310>
2016-03-04 15:28:42,178:DEBUG:letsencrypt.cli:Exiting abnormally:
Traceback (most recent call last):
  File "/root/.local/share/letsencrypt/bin/letsencrypt", line 11, in <module>
    sys.exit(main())
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/cli.py", line 1993, in main
    return config.func(config, plugins)
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/cli.py", line 658, in run
    domains = _find_domains(config, installer)
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/cli.py", line 133, in _find_domains
    domains = display_ops.choose_names(installer)
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/display/ops.py", line 217, in choose_names
    default=True)
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/display/util.py", line 156, in yesno
    yes_label=yes_label, no_label=no_label)
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/dialog.py", line 3749, in yesno
    kwargs)
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/dialog.py", line 1765, in _widget_with_no_output
    widget_name, output))
PythonDialogBug

Anyone got any clues here?

I want to build an image on top of the official Wordpress image that automatically adds Let's Encrypt.

已采纳解答

原帖链接 · vitr · CC BY-SA 3.0

I believe this could be the issue with TERM, because the client uses some terminal user interface,
but even after fixing this with export TERM=xterm, you'll hit the issue with apache restart, when the letsencrypt client restarts apache and the wordpress container has been killed immediately. Thanks to the answer How to automatically start a service when running a docker container? I've overcome this in my custom WordPress image with the tail approach, you can have a look for more ideas there, as you can see from the screenshot, it works))

update

the following steps help to fix the issue with lines in the dialog (in addition to previously applied export TERM=xterm)

apt-get install locales
locale-gen "en_US.UTF-8"
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
export LC_ALL="en_US.UTF-8"
export NCURSES_NO_UTF8_ACS=1

You can also run the client in 2 other modes

  • -t text UI mode
  • -n, --non-interactive, --noninteractive Run without ever asking for user input. This may require additional command line flags; the client will try to explain which ones are required if it finds one missing

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。