# Network\_mode host doesn't work

**URL:** <https://forums.docker.com/t/network-mode-host-doesnt-work/48048>\
**Category:** Compose\
**Created:** [March 17, 2018, 3:57pm UTC](https://forums.docker.com/t/network-mode-host-doesnt-work/48048 "2018-03-17T15:57:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![karosss1](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/karosss1/32/19252_2.png) [@karosss1](https://forums.docker.com/u/karosss1)\
**Post date:** [March 17, 2018, 3:57pm UTC](https://forums.docker.com/t/network-mode-host-doesnt-work/48048/1 "2018-03-17T15:57:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joffrey](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/joffrey/32/18458_2.png) [@joffrey](https://forums.docker.com/u/joffrey)\
**Post date:** [March 22, 2018, 8:14am UTC](https://forums.docker.com/t/network-mode-host-doesnt-work/48048/2 "2018-03-22T08:14:44Z")

</div>

Your version of Compose is severely outdated! Check out the [installation instructions for the latest version](https://github.com/docker/compose/releases/tag/1.20.1)

---

<div class="post-metadata">

**Author:** ![zbetz](https://avatars.discourse-cdn.com/v4/letter/z/c0e974/32.png) [@zbetz](https://forums.docker.com/u/zbetz)\
**Post date:** [May 31, 2018, 6:55pm UTC](https://forums.docker.com/t/network-mode-host-doesnt-work/48048/4 "2018-05-31T18:55:55Z")

</div>

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](https://forums.docker.com/t/option-network-mode-host-in-docker-compose-file-not-working-as-expected/51682)
