pika.exceptions.AMQPConnectionError - Error while running docker compose

This works for me; http://localhost:15672 is available for a browser on the host, and authenticating using guest/guest works too. So, the published ports allow any software running on the host to access it. However, you did not specify a shared network on the docker run command line, so how would another container access it? And, aha, I guess this is your problem in Compose too, as localhost in the following won’t work:

For the Compose version from your first post, you’ll need amqp://guest:guest@rabbitmq:5672 or amqp://guest:guest@my-rabbit:5672. See also Networking in Compose | Docker Docs.