Search code examples
springdockerdeploymentweb-deployment

Can't deploy spring application using WSL


The software I'm trying to deploy is https://github.com/gitbitex/gitbitex-new To sum up, it works. But only on linux machines.

Here is the script I used (from github).

# start zookeeper
docker run -d --name zookeeper-server \
  --network host \
  -e ALLOW_ANONYMOUS_LOGIN=yes \
  bitnami/zookeeper:latest

# start kafka
docker run -d --name kafka-server \
  --network host \
  -e ALLOW_PLAINTEXT_LISTENER=yes \
  -e KAFKA_CFG_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
  bitnami/kafka:latest
  
# start redis
docker run -d --name redis-server \
  --network=host \
  redis

# start mysql
docker run -d --name mysql \
  --network=host \
  -e MYSQL_ROOT_PASSWORD=123456 \
  mysql:5.7

# Please wait for MySQL to start before executing the following command
docker exec -it mysql mysql -uroot -p123456 -e "create database gitbitex;"

# start gitbitex
# open the browser and visit http://127.0.0.1/trade/BTC-USDT
docker run -d --name gitbitex \
  --network=host \
  greensheng/gitbitex

Firstly, I've tried to deploy it on vds using guide on github. And it worked without any problem.

Then I've tried to deploy it on my local machine which uses wsl with docker(integration is enabled) and it didn't work. Just can't load the webpage in browser. Curl from wsl also doesn't work, it says: connection refused.

Tried to deploy on a different linux machine, it worked again.

Tried different configuration using docker compose(cause this is what I'll need to do next). I've almost figured out how to setup it without network_mode: host but spring app itself throws exceptions anyway. With network_mode: host it doesn't work even on remote machine(but maybe it's my bad), but all containers are running properly, without errors.


Solution

  • It works on linux machine, but doesn't on Windows. As David Maze told in comments, it's because --network=host doesn't work on docker desktop. I'll try instead to setup networking put everything into compose and make it work.

    UPD: spent a lot of time trying to setup it without --network=host using docker compose and.. it still doesn't work on Windows. Docker destop is weird..