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'
services:
  python:
    build:
      context: python
      dockerfile: Dockerfile-dev
    domainname: localhost
    network_mode: host
    hostname: python
    environment:
        - PYTHONUNBUFFERED=1
        - DEBUG_ENABLE=true
    expose:
        - "8000"
    volumes:
        - ./python:/usr/src/app
    ports:
        - "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