Describe your environment
- Operating system: Debian 10
- Python Version: 3.8.10 (
python -V
)
- CCXT version: 1.59.2 (
pip freeze | grep ccxt
)
- Freqtrade Version: 2021.10 (
freqtrade -V
or docker-compose run --rm freqtrade -V
for Freqtrade running in docker)
Your question
Well, I'm trying to understand docker networking, because I'm having problems communicating two services (freqtrade + binance-proxy) without luck...
I created two containers for this, the proxy with a static IP. The gateways are the following ones:
root@DESKTOP-74LHUDF:/mnt/e/Python/freqtrade-docker# docker network inspect bot_1 | grep '"Gateway"' | head -n 1
"Gateway": "172.23.0.1"
root@DESKTOP-74LHUDF:/mnt/e/Python/freqtrade-docker# docker network inspect bot_2 | grep '"Gateway"' | head -n 1
"Gateway": "172.24.0.1"
root@DESKTOP-74LHUDF:/mnt/e/Python/freqtrade-docker# docker network inspect bot_3 | grep '"Gateway"' | head -n 1
"Gateway": "172.25.0.1"
root@DESKTOP-74LHUDF:/mnt/e/Python/freqtrade-docker# docker network inspect bot_4 | grep '"Gateway"' | head -n 1
"Gateway": "172.26.0.1"
root@DESKTOP-74LHUDF:/mnt/e/Python/freqtrade-docker# docker network inspect bot_5 | grep '"Gateway"' | head -n 1
"Gateway": "172.27.0.1"
root@DESKTOP-74LHUDF:/mnt/e/Python/freqtrade-docker# docker network inspect bot_6 | grep '"Gateway"' | head -n 1
"Gateway": "172.28.0.1"
root@DESKTOP-74LHUDF:/mnt/e/Python/freqtrade-docker# docker network inspect bot_7 | grep '"Gateway"' | head -n 1
"Gateway": "172.29.0.1"
root@DESKTOP-74LHUDF:/mnt/e/Python/freqtrade-docker# docker network inspect bot_8 | grep '"Gateway"' | head -n 1
"Gateway": "172.30.0.1"
The proxy has the following number: 172.x.0.2
. (Freqtrade I cannot know, continue reading and you will know why)
I can reach the internet using docker exec -it <container_name> ping google.com
, but I cannot reach a proxy created using binance-proxy
although I can ping it, neither I cannot httping
it nor from the host machine or from freqtrade
container.
I already tried several things but I cannot see where is the problem...
I used docker inspect
and docker network inspect
, also I tried to execute docker exec -it ... /bin/bash
to check ifconfig
and iptables
without luck, ping
works correctly:
![exec ping](https://camo.githubusercontent.com/77f9118ee651d9e728ec2d2330cdc19162363a4c18f5419cd579e9b4a72ffa90/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f64426346722e706e67)
It's working for only the first bot, I don't know if I used a command before to enable networking (on the first bot, because it works)
I don't know why I can't ping on the docker container but at least the proxy is reaching google DNS.
Also I tried static IPs without luck because gateway was missing on the docker inspect
command:
![docker inspect](https://camo.githubusercontent.com/08ef959377a81df6a14c3b7f8f0ffad43dc9fa625ad175b1c6a364f4305424f9/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f45544444582e706e67)
This is how I run it:
![bash file](https://camo.githubusercontent.com/08635601c2369ce1ea406c06f7e95d297463fb589b73c8856fc961e068e76338/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f4e506230362e706e67)
#!/bin/bash
cd /mnt/e/Python/freqtrade-docker/bot_2
docker run -w="/mnt/e/Python/freqtrade-docker/bot_2" -d --name proxy_2 --net bot_2 -p 8092:8092 nightshift2k/binance-proxy:latest
docker-compose up -d
This is my docker-compose.yml
file:
![docker-compose.yml](https://camo.githubusercontent.com/0178f2b4ef600f296ec405a73a69daacb81e925a050cd3ce1e4ca441669f9f03/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f6c575566692e706e67)
---
version: '3'
services:
freqtrade:
image: freqtradeorg/freqtrade:stable
restart: unless-stopped
container_name: freqtrade_2
volumes:
- "./user_data:/freqtrade/user_data"
# Expose api on port 8082 (localhost only)
# Please read the https://www.freqtrade.io/en/stable/rest-api/ documentation
# before enabling this.
ports:
- "127.0.0.1:8082:8082"
# - "0.0.0.0:8082:8082"
networks:
- default
# Default command used when running `docker compose up`
command: >
trade
--logfile /freqtrade/user_data/logs/freqtrade.log
--db-url sqlite:////freqtrade/user_data/tradesv3.sqlite
--config /freqtrade/user_data/config.json
--strategy xxx
networks:
default:
external: true
name: bot_2
This is my docker-compose.yml for the bot... I also tried networks
, 0.0.0.0
with http://172.x.0.2:8092/api/v3
instead of using localhost ip (127.0.0.1
)
And also I configured correctly Freqtrade config as stated here:
![config.json](https://camo.githubusercontent.com/0f1235af27f726785fff4dad89e2bb4234fd8be88f6fbfe7a38d630dbd6d6a6f/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f58394e646b2e706e67)
Maybe the problem is with the proxy, but I cannot debug correctly the bot because it's ending every time it tries to connect...
![crashes](https://camo.githubusercontent.com/05b927e09002fb5b42930928a381e78d9d6c89b84f6471851658de3bf8379386/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f65667a51582e706e67)
(Just see what does on the status column)
This exception causes the program to crash and restart:
![log exception](https://camo.githubusercontent.com/0936bc491ea832c35b8cdfafc48a6fa07bded731589f849249fb1c01fea8a360/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f6d784f62592e706e67)
![log](https://camo.githubusercontent.com/6a9d9bfc53e7a3b763eacc3b26b3e6d34e6f52cc6c7d3ab006fb0ae1a8446f66/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f64494c7a332e706e67)
Is there any way to prevent the bot to restart every time it fails?
Also, what can I try more to see where is the problem? Because I have one bot working but the other ones cannot start and the config I'm using is the same. So what's going here?
I inspected the two proxy + freqtrade containers and I don't find any differences...
configs.zip
The only thing is that when I change the cctx json config to the gateway IP it's not having any problems (in the first bot) (in this case 172.x.0.1:809x/api/v3
). But in the rest of the bots I'm having this error:
But if I do the same on the second bot, I'm having this other problem: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))