Network_mode host doesn't work

Server and client OS: Ubuntu Desktop 16.04
Docker version on server and client:

Version: 17.12.1-ce
API version: 1.35
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:17:40 2018
OS/Arch: linux/amd64

Compose version on client

docker-compose version 1.8.0, build unknown
|docker-py version: 1.9.0
CPython version: 2.7.14
OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016

New to Docker. In short - Had trouble with dns/internet access setting up remote docker machine on laptop that I don’t use and after a day of frustration found a workaround - adding --net=host parameter to docker commands, after verifying with busybox that it fixed the network problem, I found that I can define network_mode in compose file which I primarily use. However I still encounter same problem with network where it fails pulling some python packages due to name resolution failures, meanwhile if I execute exactly same commands to pull python packages on host on machine - it works without problem. So the problem should be network_mode not working.

Compose file:

version: '2'
      context: python
      dockerfile: Dockerfile-dev
    domainname: localhost
    network_mode: host
    hostname: python
        - DEBUG_ENABLE=true
        - "8000"
        - ./python:/usr/src/app
        - "8000:8000"

Or maybe it is possible to make docker attach --net=host parameter to each command it executes, since as much as I understand docker, compose is a wrapper for Docker and executes docker commands itself?

I absolutely don’t care about security and other problems using host network might introduce - as a remote server I am using old laptop which is not used for anything else, so no data or whatever I care bout there and it’s for small personal projects, nothing important.

1 Like

Your version of Compose is severely outdated! Check out the installation instructions for the latest version

I removed my original reply to this topic and moved it to its own topic, where I explained my similar issue in more detail: Option network_mode: host in docker compose file not working as expected