title: Springboot with Docker: environment variable to override RabbitMQ host IP property in spring boot's application.properties is not working
body: <p>I am working on spring boot application where I have to use RabbitMQ as a message broker. Instead of using RabbitMQ on my localhost, I am using docker image from docker hub using below command</p>
  <pre><code>docker run -d --name rabbit-name-management -p 15672:15672 -p 5672:5672 -p 15671:15671 -p 5671:5671 -p 4369:4369 rabbitmq:3-management
  </code></pre>
  <p>So it pulls the image and running successfully as a docker container.</p>
  <p>Now in my spring boot application, I use an <code>application.properties</code> file in order to connect to <code>RabbitMQ</code> and which looks like as shown below:</p>
  <pre><code>spring.rabbitmq.host=localhost
  spring.rabbitmq.port=5672
  spring.rabbitmq.username=*****
  spring.rabbitmq.password=********
  </code></pre>
  <p><strong>My spring boot docker file</strong></p>
  <pre><code>FROM openjdk:8-jdk-alpine
  VOLUME /tmp
  COPY encryptionKey.jks encryptionKey.jks
  COPY UnlimitedJCEPolicyJDK8/* /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/
  COPY target/ConfigServer-0.0.1-SNAPSHOT.jar ConfigServer.jar
  ENTRYPOINT [&quot;java&quot;,&quot;-Djava.security.egd=file:/dev/./urandom&quot;,&quot;-jar&quot;,&quot;ConfigServer.jar&quot;]
  </code></pre>
  <p>I used command <code>docker inspect &lt;RABBITMQ_CONTAINER_ID&gt;</code> to find out the IP address of the machine where RabbitMQ is running. And in order to make it communicate with RabbitMQ I am using environment variable to override localhost with the actual IP address of the container where RabbitMQ is running. And the docker command for this is as below</p>
  <pre><code>docker run -p 8012:8012 -e &quot;spring.rabbitmq.host=http://172.17.0.3&quot; config-server
  </code></pre>
  <p>But this command is getting failed and it logs the error as below</p>
  <pre><code>2020-08-20 06:10:31.077 ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed
   
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address http://172.17.0.3:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
          at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:635) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
          at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
          at com.appsdeveloperblog.photoapp.api.PhotoAppApiConfigServerApplication.main(PhotoAppApiConfigServerApplication.java:12) [classes!/:0.0.1-SNAPSHOT]
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_212]
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_212]
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_212]
          at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_212]
          at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [ConfigServer.jar:0.0.1-SNAPSHOT]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) [ConfigServer.jar:0.0.1-SNAPSHOT]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [ConfigServer.jar:0.0.1-SNAPSHOT]
          at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [ConfigServer.jar:0.0.1-SNAPSHOT]
  Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address http://172.17.0.3:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
          at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          ... 28 common frames omitted
  Caused by: java.lang.IllegalArgumentException: Address http://172.17.0.3:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
          at com.rabbitmq.client.Address.parseHost(Address.java:96) ~[amqp-client-5.9.0.jar!/:5.9.0]
          at com.rabbitmq.client.Address.parseAddress(Address.java:158) ~[amqp-client-5.9.0.jar!/:5.9.0]
          at com.rabbitmq.client.Address.parseAddresses(Address.java:173) ~[amqp-client-5.9.0.jar!/:5.9.0]
          at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.setAddresses(AbstractConnectionFactory.java:299) ~[spring-rabbit-2.2.10.RELEASE.jar!/:2.2.10.RELEASE]
          at org.springframework.boot.context.properties.PropertyMapper$Source.to(PropertyMapper.java:316) ~[spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
          at org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration$RabbitConnectionFactoryCreator.rabbitConnectionFactory(RabbitAutoConfiguration.java:102) ~[spring-boot-autoconfigure-2.3.3.RELEASE.jar!/:2.3.3.RELEASE]
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_212]
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_212]
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_212]
          at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_212]
          at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
          ... 29 common frames omitted
  </code></pre>
  <p>I don't have any idea what is this <code>unquoted IPv6 address</code> and why it is complaining about it here and what am I supposed to do here to remove this error.</p>