一、搜索镜像
[root@localhost ~]# docker search rabbitmq
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
rabbitmq RabbitMQ is an open source multi-protocol me… 4887 [OK]
bitnami/rabbitmq Bitnami Docker Image for RabbitMQ 103 [OK]
这里我们选择bitname/rabbitmq
二、下载镜像
[root@localhost ~]# docker pull bitnami/rabbitmq
Using default tag: latest
latest: Pulling from bitnami/rabbitmq
三、把RabbitMQ镜像跑起来
docker run -d --name rabbitmq \
-e RABBITMQ_USERNAME=admin \
-e RABBITMQ_PASSWORD=admin \
-p 15672:15672 -p 5672:5672 -p 25672:25672 -p 61613:61613 -p 1883:1883 bitnami/rabbitmq
其中RABBITMQ_USERNAME是用户名
RABBITMQ_PASSWORD是密码
关于更多环境变量的说明,见文末
四、查看运行效果
看一下docker容器是否成功启动了,下面可以看到正在运行
[root@localhost ~]# docker ps | grep rabbit
0d5cb60e3a06 bitnami/rabbitmq "/opt/bitnami/script…" 22 seconds ago Up 20 seconds 4369/tcp, 5551-5552/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0.0.0:25672->25672/tcp, :::25672->25672/tcp, 0.0.0.0:61613->61613/tcp, :::61613->61613/tcp, 15671/tcp rabbitmq
输入地址访问一下控制台
http://192.168.56.201:15672/#/
用户名:admin,密码admin
登录成功
到此为止,我们就可以愉快地和RabbitMQ玩耍了
五、关于环境变量的说明
(来源于官网)
RABBITMQ_VHOST: RabbitMQ application vhost. Default: /
RABBITMQ_VHOSTS: List of additional virtual host (vhost), separated by space. E.g.: /shared /prioritized /tasks
RABBITMQ_USERNAME: RabbitMQ application username. Default: user
RABBITMQ_PASSWORD: RabbitMQ application password. Default: bitnami
RABBITMQ_SECURE_PASSWORD: Whether to set the RabbitMQ password securely. This is incompatible with loading external RabbitMQ definitions. Default: no
RABBITMQ_LOAD_DEFINITIONS: Whether to load external RabbitMQ definitions. This is incompatible with setting the RabbitMQ password securely. Default: no.
RABBITMQ_ERL_COOKIE: Erlang cookie to determine whether different nodes are allowed to communicate with each other.
RABBITMQ_NODE_TYPE: Node Type. Valid values: stats, queue-ram or queue-disc. Default: stats
RABBITMQ_NODE_NAME: Node name and host. E.g.: node@hostname or node (localhost won't work in cluster topology). Default rabbit@localhost. If using this variable, ensure that you specify a valid host name as the container wil fail to start otherwise. If using a fully qualified domain name, RABBITMQ_USE_LONGNAME needs to be set to true as well.
RABBITMQ_USE_LONGNAME: When set to true this will cause RabbitMQ to use fully qualified names to identify nodes. Default: false
RABBITMQ_FORCE_BOOT: Force a node to start even if it was not the last to shut down. Default: no
RABBITMQ_CLUSTER_NODE_NAME: Node name to cluster with. E.g.: clusternode@hostname
RABBITMQ_CLUSTER_PARTITION_HANDLING: Cluster partition recovery mechanism. Default: ignore
RABBITMQ_NODE_PORT_NUMBER: Node port. Default: 5672
RABBITMQ_NODE_SSL_PORT_NUMBER: RabbitMQ node port number for SSL connections. Default: 5671
RABBITMQ_SSL_CACERTFILE: Path to the RabbitMQ server SSL CA certificate file. No defaults.
RABBITMQ_SSL_CERTFILE: Path to the RabbitMQ server SSL certificate file. No defaults.
RABBITMQ_SSL_KEYFILE: Path to the RabbitMQ server SSL certificate key file. No defaults.
RABBITMQ_COMBINED_CERT_PATH: Cert- and keyfile are combined automatically into one combined file at this file path. If you are using a combined certificate anyways, mount it to the container and set this path to the mounted file. Default: /tmp/rabbitmq_combined_keys.pem
RABBITMQ_SSL_DEPTH: Maximum number of non-self-issued intermediate certificates that may follow the peer certificate in a valid certification path. No defaults.
RABBITMQ_SSL_FAIL_IF_NO_PEER_CERT: Whether to reject TLS connections if client fails to provide a certificate. Default: verify_none
RABBITMQ_SSL_VERIFY: Whether to enable peer SSL certificate verification. Default: no
RABBITMQ_PLUGINS: Comma, semi-colon or space separated list of plugins to enable during the initialization. No defaults.
RABBITMQ_COMMUNITY_PLUGINS: Comma, semi-colon or space separated list of URLs where to download custom plugins during the initialization. No defaults.
Management server configuration
RABBITMQ_MANAGEMENT_BIND_IP: RabbitMQ management server bind IP address. Default: 0.0.0.0
RABBITMQ_MANAGEMENT_PORT_NUMBER: RabbitMQ management server port number. Default: 15672
RABBITMQ_MANAGEMENT_SSL_PORT_NUMBER: RabbitMQ management server port number for SSL/TLS connections. No defaults.
RABBITMQ_MANAGEMENT_SSL_CACERTFILE: Path to the RabbitMQ management server SSL CA certificate file. No defaults.
RABBITMQ_MANAGEMENT_SSL_CERTFILE: Path to the RabbitMQ management server SSL certificate file. No defaults.
RABBITMQ_MANAGEMENT_SSL_KEYFILE: Path to the RabbitMQ management server SSL certificate key file. No defaults.
RABBITMQ_MANAGEMENT_SSL_DEPTH: Maximum number of non-self-issued intermediate certificates that may follow the peer certificate in a valid certification path, for the RabbitMQ management server. No defaults.
RABBITMQ_MANAGEMENT_SSL_FAIL_IF_NO_PEER_CERT: Whether to reject TLS connections if client fails to provide a certificate for the RabbitMQ management server. Default: yes
RABBITMQ_MANAGEMENT_SSL_VERIFY: Whether to enable peer SSL certificate verification for the RabbitMQ management server. Default: verify_peer
LDAP configuration
RABBITMQ_ENABLE_LDAP: Enable the LDAP configuration. Defaults: no
RABBITMQ_LDAP_TLS: Enable secure LDAP configuration. Defaults: no
RABBITMQ_LDAP_SERVERS: Comma, semi-colon or space separated list of LDAP server hostnames. No defaults.
RABBITMQ_LDAP_SERVERS_PORT: LDAP servers port. Defaults: 389
RABBITMQ_LDAP_USER_DN_PATTERN: DN used to bind to LDAP in the form cn=$${username},dc=example,dc=org. No defaults.
Memory and disk configuration
RABBITMQ_VM_MEMORY_HIGH_WATERMARK: High memory watermark for RabbitMQ to block publishers and prevent new messages from being enqueued. Can be specified as an absolute or relative value (as percentage or value between 0 and 1). No defaults.
RABBITMQ_DISK_FREE_RELATIVE_LIMIT: Disk relative free space limit of the partition on which RabbitMQ is storing data. Default: 1.0
RABBITMQ_DISK_FREE_ABSOLUTE_LIMIT: Disk absolute free space limit of the partition on which RabbitMQ is storing data (takes precedence over the relative limit). No defaults.
RABBITMQ_ULIMIT_NOFILES: Resources limits: maximum number of open file descriptors. Default: 65536