I have a spring boot application. On request it executes tcpdump as shown below
String cmd = "tcpdump -n host " + this.host;
Process process = Runtime.getRuntime().exec(cmd);
InputStream stream = process.getInputStream();
...
I wanted to dockerize this application to work on other OS than linux so i prepared Dockerfile:
FROM openjdk:15-alpine
RUN apk --no-cache add tcpdump
COPY target/app.jar /usr/src/app.jar
CMD java ... (runs spring app)
and docker-compose
version: '3.5'
services:
service_name:
network_mode: host
container_name: service_name
build:
context: .
environment:
- TZ=Europe/Warsaw
- spring.profiles.active=development
- spring.liquibase.contexts=development
I expected network_mode: host
to make docker use host network so it could be scanned and that it could receive on request to spring applications, but as tests have shown me that is not the case. Why and how can i fix that?
I've read in docs that:
Because of the way networking is implemented in Docker Desktop for Windows, you cannot see a docker0 interface on the host. This interface is actually within the virtual machine.
Does that mean, that i cannot connect to host machnine from docker on windows? How can i awoid that?