Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set the container hostname property for RabbitMQ Docker containers? #1186

Closed
CyrusZhou-CN opened this issue Dec 4, 2023 · 2 comments
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-orchestrator

Comments

@CyrusZhou-CN
Copy link

CyrusZhou-CN commented Dec 4, 2023

I am using the following code to create three RabbitMQ Docker containers and want to test their behavior as nodes. I would like to set the hostname property for the containers to easily identify and manage them.

var builder = DistributedApplication.CreateBuilder(args);

var rabbitMq = builder.AddRabbitMQContainer("EventBus");
rabbitMq.WithEnvironment("RABBITMQ_ERLANG_COOKIE", "secretcookie");
rabbitMq.WithVolumeMount("rabbitmq-node.config", "/etc/rabbitmq/rabbitmq.config");

var rabbitMq1 = builder.AddRabbitMQContainer("EventBus1");
rabbitMq1.WithEnvironment("RABBITMQ_ERLANG_COOKIE", "secretcookie");
rabbitMq1.WithVolumeMount("rabbitmq-node.config", "/etc/rabbitmq/rabbitmq.config");

var rabbitMq2 = builder.AddRabbitMQContainer("EventBus2");
rabbitMq2.WithEnvironment("RABBITMQ_ERLANG_COOKIE", "secretcookie");
rabbitMq2.WithVolumeMount("rabbitmq-node.config", "/etc/rabbitmq/rabbitmq.config");

How should I set the hostname property to facilitate testing and managing these RabbitMQ containers?

docker-compose.yml

version: '3.8'

services:
  rabbitmq-node1:
    image: "rabbitmq:3-management"
    container_name: "rabbitmq-node1"
    hostname: rabbitmq-node1
    ports:
      - "5672:5672"
      - "15672:15672"
    environment:
      RABBITMQ_ERLANG_COOKIE: "secretcookie" 
    volumes:
      - ./rabbitmq-node1.config:/etc/rabbitmq/rabbitmq.config
    networks:
      - rabbitmq-cluster

  rabbitmq-node2:
    image: "rabbitmq:3-management"
    container_name: "rabbitmq-node2"
    hostname: rabbitmq-node2
    ports:
      - "5673:5672"
      - "15673:15672"
    environment:
      RABBITMQ_ERLANG_COOKIE: "secretcookie"
    volumes:
      - ./rabbitmq-node2.config:/etc/rabbitmq/rabbitmq.config
    networks:
      - rabbitmq-cluster

  rabbitmq-node3:
    image: "rabbitmq:3-management"
    container_name: "rabbitmq-node3"
    hostname: rabbitmq-node3
    ports:
      - "5674:5672"
      - "15674:15672"
    environment:
      RABBITMQ_ERLANG_COOKIE: "secretcookie"
    volumes:
      - ./rabbitmq-node3.config:/etc/rabbitmq/rabbitmq.config
    networks:
      - rabbitmq-cluster

networks:
  rabbitmq-cluster:
    driver: bridge
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-integrations Issues pertaining to Aspire Integrations packages label Dec 4, 2023
@davidfowl
Copy link
Member

Dupe of #949

@CyrusZhou-CN CyrusZhou-CN changed the title How to set the container_name property for RabbitMQ Docker containers? How to set the container hostname property for RabbitMQ Docker containers? Dec 4, 2023
@davidfowl davidfowl added area-orchestrator area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication and removed area-integrations Issues pertaining to Aspire Integrations packages labels Dec 4, 2023
@dbreshears
Copy link
Contributor

This is scheduled for Preview 3.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-orchestrator
Projects
None yet
Development

No branches or pull requests

3 participants