本文介绍了在docker-compose文件中提供rabbitmq.conf会给出“ sed:无法重命名/ etc / rabbitmq / sedMaHqMa:设备或资源繁忙”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的docker-compose看起来像这样:

 版本:'3.2'
服务:
mq:
主机名:$ {HOST_NAME}
端口:
- 5671:5671
- 5672:5672
- 15671:15671
- 15672:15672
环境:
-RABBITMQ_DEFAULT_USER = $ {USER}
-RABBITMQ_DEFAULT_PASS = $ {RABBITMQ_DEFAULT_PASS}
量:
-$ {CACERT_PEM_FILE }:/ etc / rabbitmq / certs / cacert.pem
-$ {CERT_PEM_FILE}:/ etc / rabbitmq / certs / cert.pem
-$ {KEY_PEM_FILE}:/ etc / rabbitmq / certs / key .pem
-$ {MQ_CONFIG_FILE}:/ etc / rabbitmq / rabbitmq.conf
图片:rabbitmq:3-management

我的rabbitmq.conf看起来像这样:

  listeners.tcp.default = 5672 
listeners.ssl.default = 5671

ssl_options.cacertfile = /etc/rabbitmq/certs/cacert.pem
ssl_options.certfile = /etc/rabbitmq/certs/cert.pem
ssl_options.keyfile = / etc / rabbitmq / certs / key.pem
ssl_options.verify = verify_peer
ssl_options.fail_if_no_peer_cert = false

ssl_options.versions.1 = tlsv1.2
ssl_options.versions.2 = tlsv1.1

但是当我尝试执行 docker-compose 时, code>我收到以下错误:



无法重命名/ etc / rabbitmq / sedMaHqMa:设备或资源繁忙



我尝试使用配置文件(rabbitmq.config)的旧格式,但没有出现此错误,但是我需要使用新格式,因为我需要在启动过程中通过环境提供的密码。



编辑二月20,2018



这里是 Rabbitmq docker映像中当前可用的环境变量,它们足以为AMQP和HTTP设置TLS(管理API和Web控制台)



将其复制以防链接断开:



'pre> RABBITMQ_DEFAULT_PASS
RABBITMQ_DEFAULT_USER
RABBITMQ_DEFAULT_VHOST
RABBITMQ_ERLANG_COOKIE
RABBITMQ_HIPE_COMPILE
RABBITMQ_MANAGEMENT_SSL_CACERTFILE
RABBITMQ_MANAGEMENT_SSL_CERTFILE
RABBITMQ_MANAGEMENT_SSL_DEPTH
RABBITMQ_MANAGEMENT_SSL_FAIL_IF_NO_PEER_CERT
RABBITMQ_MANAGEMENT_SSL_KEYFILE
RABBITMQ_MANAGEMENT_SSL_VERIFY
RABBITMQ_SSL_CACERTFILE
RABBITMQ_SSL_CERTFILE
RABBITMQ_SSL_DEPTH
RABBITMQ_SSL_FAIL_IF_NO_PEER_CERT
RABBITMQ_SSL_KEYFILE
RABBITMQ_SSL_VERIFY
RABBITMQ_VM_MEMORY_HIGH_WATERMARK


解决方案

这似乎是一个问题使用当前的rabbitmq
Dockerfile。特别是 sed 命令在映射为卷的配置文件上似乎无法正常工作。但是,由于您仍然可以控制 rabbitmq.conf ,为什么不在此文件中包含默认用户和密码

  default_user =管理员
default_pass = YourStrongPasswort

和 RABBITMQ_DEFAULT_USER和RABBITMQ_DEFAULT_PASS。
这可能是最快的解决方法。刚刚测试过,对我有用(官方Rabbitmq:3.7-management)。


My docker-compose looks like this:

version: '3.2'
services:
  mq:
    hostname: ${HOST_NAME}
    ports:
      - "5671:5671"
      - "5672:5672"
      - "15671:15671"
      - "15672:15672"
    environment:
      - RABBITMQ_DEFAULT_USER=${USER}
      - RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
    volumes:
      - ${CACERT_PEM_FILE}:/etc/rabbitmq/certs/cacert.pem
      - ${CERT_PEM_FILE}:/etc/rabbitmq/certs/cert.pem
      - ${KEY_PEM_FILE}:/etc/rabbitmq/certs/key.pem
      - ${MQ_CONFIG_FILE}:/etc/rabbitmq/rabbitmq.conf
    image: rabbitmq:3-management

My rabbitmq.conf looks like this:

listeners.tcp.default = 5672
listeners.ssl.default = 5671

ssl_options.cacertfile = /etc/rabbitmq/certs/cacert.pem
ssl_options.certfile = /etc/rabbitmq/certs/cert.pem
ssl_options.keyfile = /etc/rabbitmq/certs/key.pem
ssl_options.verify = verify_peer
ssl_options.fail_if_no_peer_cert = false

ssl_options.versions.1 = tlsv1.2
ssl_options.versions.2 = tlsv1.1

However when I try to do docker-compose up I get the following error:

cannot rename /etc/rabbitmq/sedMaHqMa: Device or resource busy

I tried using old format of config file (rabbitmq.config) and it was not giving me this error, however I need to use new format because I need the password to be provided by during the startup via env. variables.

EDIT Feb 20, 2018

Here is a list of currently available environmental variables in Rabbitmq docker image, and they are enough to setup TLS for both AMQP and HTTP (management API and Web Console)

Copying them in case the link will become broken:

RABBITMQ_DEFAULT_PASS
RABBITMQ_DEFAULT_USER
RABBITMQ_DEFAULT_VHOST
RABBITMQ_ERLANG_COOKIE
RABBITMQ_HIPE_COMPILE
RABBITMQ_MANAGEMENT_SSL_CACERTFILE
RABBITMQ_MANAGEMENT_SSL_CERTFILE
RABBITMQ_MANAGEMENT_SSL_DEPTH
RABBITMQ_MANAGEMENT_SSL_FAIL_IF_NO_PEER_CERT
RABBITMQ_MANAGEMENT_SSL_KEYFILE
RABBITMQ_MANAGEMENT_SSL_VERIFY
RABBITMQ_SSL_CACERTFILE
RABBITMQ_SSL_CERTFILE
RABBITMQ_SSL_DEPTH
RABBITMQ_SSL_FAIL_IF_NO_PEER_CERT
RABBITMQ_SSL_KEYFILE
RABBITMQ_SSL_VERIFY
RABBITMQ_VM_MEMORY_HIGH_WATERMARK
解决方案

This seem to be an issue with current rabbitmqDockerfile. Particulary sed command seem not work properly on configfile mapped as volume. However as you have control over your rabbitmq.conf anyway, why not include default user and password to this file

default_user = admin
default_pass = YourStrongPasswort

and remove RABBITMQ_DEFAULT_USER and RABBITMQ_DEFAULT_PASS out of your compose file.This is fastest work-around probably. Just tested, works for me (official rabbitmq:3.7-management).

这篇关于在docker-compose文件中提供rabbitmq.conf会给出“ sed:无法重命名/ etc / rabbitmq / sedMaHqMa:设备或资源繁忙”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 07:20