Option network_mode: host in docker compose file not working as expected

I had a similar problem where after connecting to a VPN, my containers couldn’t access the internet. I’ve managed to solve this by adding the network flag to the builds section of my compose files:

version: '3.4'
serivces:
  some_service:
  build:
    network: host
    ...

Hope that helps!

6 Likes