RabbitMQ on docker: Failed to check/redeclare auto-delete queue(s) - windows

In my java spring-boot app time to time I get this error.
Restarting docker and starting container again fixes it.
But I want to know how can I deal with it faster?
Docker logs do not give me anything - for example issue occurred now (14:25) but logs are old:
2019-02-04 13:19:41.885 [error] <0.1509.0> closing AMQP connection <0.1509.0> (172.17.0.1:55060 -> 172.17.0.2:5672 - rabbitConnectionFactory#6049c421:648):
missed heartbeats from client, timeout: 60s
2019-02-04 13:19:41.903 [error] <0.1517.0> closing AMQP connection <0.1517.0> (172.17.0.1:55064 -> 172.17.0.2:5672 - rabbitConnectionFactory#575a1719:1056):
missed heartbeats from client, timeout: 60s
PS C:\Users\user> docker logs -f rabbit-fox
I created this container by following command:
docker run -d --hostname my-rabbit --name rabbit-fox -p 5672:5672 -p 8090:15672 rabbitmq:3-management

I used a different port to expose 4369:4369, you can try. I dont know the reason but its worked for me. In the rabbit documentation is said about this port, you can see more in https://www.rabbitmq.com/networking.html

Related

can't connect to docker container localhost connection refused

very new to docker. following this tutorial: https://medium.com/thecodefountain/develop-a-spring-boot-and-mysql-application-and-run-in-docker-end-to-end-15b7cdf3a2ba
I followed all the instructions (my application is called accessing-data-mysql) but I think I should have two containers running: one for mysql and one for the application. But when running docker container ls I only see the mysql container listed. Below I am creating a docker container for my application's image and linking it to the running instance of mysql container.
PS C:\projects\project1> docker run -d -p 8089:8089 --name accessing-data-mysql --link mysql-standalone:mysql accessing-data-mysql
82f499c6897d1f6bd2eeaabe4aa25ae786508146929a7039785e4ca37d691435
PS C:\projects\project1> docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62029a53b9d4 mysql "docker-entrypoint.s…" 16 minutes ago Up 16 minutes 3306/tcp, 33060/tcp mysql-standalone
PS C:\projects\project1> docker run -d -p 8089:8089 --name accessing-data-mysql --link mysql-standalone:mysql accessing-data-mysql
my docker file:
FROM openjdk:12
ADD target/user-mysql.jar user-mysql.jar
EXPOSE 8089
ENTRYPOINT ["java", "-jar", "user-mysql.jar"]
when connecting via browser to localhost:8089, I get connection refused error. Not even sure if the service is running.
below is the result of running docker logs:
PS C:\projects\project1> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
82f499c6897d accessing-data-mysql "java -jar accessing…" 50 minutes ago Exited (0) 50 minutes ago accessing-data-mysql
62029a53b9d4 mysql "docker-entrypoint.s…" About an hour ago Up About an hour 3306/tcp, 33060/tcp mysql-standalone
PS C:\projects\project1> docker logs accessing-data-mysql
Hibernate ORM core version 5.4.27.Final
PS C:\projects\project1>
EDIT:
When I run locally directly from Idea, I see the error: No such host is known (mysql-standalone), which is the mysql url I configured to connect to docker mysql. As soon as I change the mysql url to localhost:3306, it can connect. Does this mean that somehow the my-sql docker instance is not accepting connections?
Your container is not up and running. You need to see the container as up when you do docker ps. You should see something like this:
~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62029a53b9d4 mysql "docker-entrypoint.s…" 16 minutes ago Up 16 minutes 3306/tcp, 33060/tcp mysql-standalone
XXXXXXXXXXXX openjdk "java" XX minutes ago Up xx minutes 8089/tcp accessing-data-mysql
If you are not able to see the second container, it means it's not running. You will need to find the reason for not running by getting the logs with docker logs accessing-data-mysql and see why the second container is not starting.
Also, consider creating a docker-compose for both containers and establish a separate network. This is not required, your example can work without this, but it makes the things much easier for management and also for troubleshooting.

Not being able to create an end point. Error with specified port

I use following commands to run my project.
docker run -it -p 8080:80 --rm -v "d:\project1:/var/www/html" myimage....
This was running fine till yesterday. But when I tried the same command, I am getting error
docker: Error response from daemon: failed to create endpoint loving_dubinsky on network nat: hnsCall failed in Win32: The specified port already exists. (0x803b0013).
I checked if 8080 port is being used or not using following command.
netstat -ano | findstr :8080
I could not see this port is being used.
How can I fix this issue?
Thank You.
Run "docker ps" command.
From "docker ps" output, you will come to know if there is any container which is listening to port 8080.
You can kill that container using "docker kill container_id".
Now your port 8080 will be free.

unable to start kafka and zookeeper using docker; ports 9092 and 2181 are already allocated

I am trying to statrt kafka and zookeeper using this docker file
version: '2'
services:
kafka:
image: landoop/fast-data-dev:cp3.3.0
hostname: kafka-host
ports:
- 29092:29092
- 3030:3030 # Landoop UI
- 8081-8083:8081-8083 # REST Proxy, Schema Registry, Kafka Connect ports
- 9581-9585:9581-9585 # JMX Ports
- 2181:2181 # Zookeeper
- 9092:9092 # Kafka Broker
environment:
ADV_HOST: 127.0.0.1
RUNTESTS: 0
FORWARDLOGS: 0
SAMPLEDATA: 0
but I keep on receiving this error message
Cannot start service kafka: b'driver failed programming external connectivity on endpoint kafka-docker_kafka_1 (a741da2d21a00bb752fc169d579fa39bcdeef0cc88ec560d2e93b8fd287b8b5a): Error starting userland proxy: Bind for 0.0.0.0:9092 failed: port is already allocated'
even after I remove all the images and containers ...
with "sudo lsof -i tcp:9092"
I see some process are going on ... but even after I kill them, using kill -9 PIDsome other appear ...
I solved the problem; kafka and zookeeper were actually already installed locally and brew were running them in the background ... when I uninstalled them, everything was fine!
It seems that one of your containers is still using port 9092 (as sudo lsof -i tcp:9092 shows). Run docker ps to be sure that there is no container running using this port.
Moreover, stopping containers using kill -9 command is not the right way :
if you're using docker-compose (as your example shows), you can run docker-compose down to stop all services (therefore all containers defined in your file). Alternatively, if you want to shutdown a container using only docker command, you have to run docker stop <container_id_or_name>, but I do not recommend that if you're using docker-compose
when you issue a kill -9 command, you're experiencing that containers are restarting over and over because you probably have defined a restart policy on your service (https://docs.docker.com/compose/compose-file/compose-file-v2/#restart). The container started after the other one have exited (caused by kill -9) is using the same ports as the previous, so port 9092 is always used

Docker on Mac is running but refusing to expose port

Mac here, running Docker Community Edition Version 17.12.0-ce-mac49 (21995).
I have Dockerized a web app with a Dockerfile like so:
FROM openjdk:8
RUN mkdir /opt/myapp
ADD build/libs/myapp.jar /opt/myapp
ADD application.yml /opt/myapp
ADD logback.groovy /opt/myapp
WORKDIR /opt/myapp
EXPOSE 9200
ENTRYPOINT ["java", "-Dspring.config=.", "-jar", "myapp.jar"]
I then build that image like so:
docker build -t myapp .
I then run a container of that image like so:
docker run -it -p 9200:9200 --net="host" --env-file ~/myapp-local.env --name myapp myapp
In the console I see the app start up without any errors, and all seems to be well. Even my metrics publishes (which publish heartbeat and other health metrics every 20 seconds) are printing to the console as I would expect them to. Everything seems to be fine.
Except when I go to run a curl against my app from another terminal/session:
curl -i -H "Content-Type: application/json" -X POST -d '{"username":"heyitsme","password":"12345"}' http://localhost:9200/v1/auth/signIn
curl: (7) Failed to connect to localhost port 9200: Connection refused
Now, if this were a situation where the /v1/auth/signIn path wasn't valid, or if there was something wrong with my request entity/payload, the server would pick up on it and send an error (I assure you; as I can confirm this exact same curl works when I run the server outside of Docker as just a standalone service).
So this is definitely a situation where the curl command can't connect to localhost:9200. Again, when I run my app outside of Docker, that same curl command works perfectly, so I know my app is trying to standup on port 9200.
Any ideas as to what could be going wrong here, or how I could begin troubleshooting?
The way you run your container has 2 conflicting parts:
-p 9200:9200 says: "publish (bind) port 9200 of the container to port 9200 of the host"
--net="host" says: "use the host's networking stack"
According to Docker for Mac - Networking docs / Known limitations, use cases, and workarounds, you should only publish a port:
I want to connect to a container from the Mac
Port forwarding works for localhost; --publish, -p, or -P all work. Ports exposed from Linux are forwarded to the Mac.
Our current recommendation is to publish a port, or to connect from another container. This is what you need to do even on Linux if the container is on an overlay network, not a bridge network, as these are not routed.
The command to run the nginx webserver shown in Getting Started is an example of this.
$ docker run -d -p 80:80 --name webserver nginx
Check that your app bind to 0.0.0.0:9200 and not localhost:9200 or something similar
Problem seems to be in the network mode you are running the container.
Quick test: Login to your container and run the curl cmd there, hopefully it works. That would isolate the problem to request not being forwarded from host to container.
Try running your container on the default bridge network and test.
Refer to this blog for details on the network modes in docker
TLDR; You will need to add an IPtables entry to allow the traffic to enter your container.

Setting redis configuration with docker in windows

I want to set up redis configuration in docker.
I have my own redis.conf under D:/redis/redis.conf and have configured it to have bind 127.0.0.1 and have uncommented requirepass foobared
Then used this command to load this configuration in docker:
docker run --volume D:/redis/redis.conf:/usr/local/etc/redis/redis.conf --name myredis redis redis-server /usr/local/etc/redis/redis.conf
Next,
I have docker-compose.yml in my application in maven Project under src/resources.
I have the following in my docker-compase.yml
redis:
image: redis
ports:
- "6379:6379"
And i execute the command :
docker-compose up
The Server runs, but when i check with the command:
docker ps -a
it Shows that redis Image runs at 0.0.0.0:6379.
I want it to run at 127.0.0.1.
How do i get that?
isn't my configuration file loading or is it wrong? or my commands are wrong?
Any suggestions are of great help.
PS: I am using Windows.
Thanks
Try to execute:
docker inspect <container_id>
And use "NetworkSettings"->"Gateway" (it must be 172.17.0.1) value instead of 127.0.0.1.
You can't use 127.0.0.1 as your Redis was run in the isolated environment.
Or you can link your containers.
So first of all you should not be worried about redis saying listening on 0.0.0.0:6379. Because redis is running inside the container. And if it doesn't listen on 0.0.0.0 then you won't be able to make any connections.
Next if you want redis to only listen on localhost on localhost then you need to use below
redis:
image: redis
ports:
- "127.0.0.1:6379:6379"
PS: I have not run container or docker for windows with 127.0.0.1 port mapping, so you will have to see if it works. Because host networking in Windows, Mac and Linux are different and may not work this way

Resources