1

there's something I'm not getting from the new docker compose configuration file:

here's my Dockerfile:

FROM ubuntu

run apt-get update && \
    apt-get install -y netcat net-tools tcpdump

CMD tcpdump -i eth0 -XX

here's my docker-compose.yml:

version: '3.7'
services:
  server:
    build: ./
    image: srv
    container_name: srv

  client: 
    build: ./
    image: clnt
    container_name: clnt

I open three consoles:

%1 docker-compose up --force-recreate --build

builds and starts showing network traffic

%2 docker exec -it srv /bin/bash
%2 nc -lp 4001 &

%3 docker exec -it clnt /bin/bash
%3 nc srv 4001

I can see messages being shared back and forth between the two containers, but tcpdump doesn't report any of these messages, is not docker using eth0 for these connections?

I'm confused.

Don Giulio
  • 2,946
  • 3
  • 43
  • 82
  • 2
    There's no natural/default link between docker's bridge and host's eth0. You should use --net=host. Take a look here: https://stackoverflow.com/questions/37536687/what-is-the-relation-between-docker0-and-eth0 – aran Mar 27 '19 at 11:50
  • Possible duplicate of [What is the relation between docker0 and eth0?](https://stackoverflow.com/questions/37536687/what-is-the-relation-between-docker0-and-eth0) – Software Engineer Mar 27 '19 at 23:42

0 Answers0