Docker compose running containers in net host

+1 vote

I want to spawn 3 services in the "host" net using docker-compose. Here is my docker-compose.yml file:

version: '2'
services:
  mysql:
    image: mysql
    net: "host"
  nginx:
    image: nginx
    net: "host"
  app:
    image: tomcat
    net: "host"

I got the following error:

$ docker-compose up
[31mERROR[0m: Validation failed in file '.\docker-compose.yml', reason(s):
Unsupported config option for services.app: 'net'
Unsupported config option for services.mysql: 'net'
Unsupported config option for services.nginx: 'net'

I'm using boot2docker on windows.

Docker, and Docker-compose version:

$ docker -v
Docker version 1.10.2, build c3959b1
$ docker-compose -version
docker-compose version 1.6.0, build cdb920a

If I run all services manually by using docker run --net = "host" everything is working fine.

Jul 31, 2018 in Docker by Hannah
• 18,520 points
5,422 views

4 answers to this question.

0 votes

Just print

network_mode: "host"

This might not work for Mac.

answered Jul 31, 2018 by Kalgi
• 52,350 points
network_node worked like a charm, Thanks @Kalgi
+1 vote
This is most probably a syntax error. Please check your code's indentation.
answered Apr 26, 2019 by Gargi
Hey @Gargi, the syntax seems fine to me. Can you please share some syntax reference I can compare my syntax with? That would be very helpful

Have a look at this for understanding the syntax.

+1 vote

The reason for this error is that there is an attempt to use a compose file option that is incompatible with the engine version that you're using against. 

In your case, the compose version is 1.6 and you're using version 2 in your Dockerfile.

answered May 7, 2019 by Aliba
+1 vote

Hey@Hannah, Check the compose file format specifications and compatibility matrix for what version of the file supports your option.

answered May 7, 2019 by Kishore

Related Questions In Docker

0 votes
0 answers
0 votes
1 answer

Different file owner inside Docker container and in host machine Ask

Filesystems, at least in Unix- and Linux-like ...READ MORE

answered Jun 25, 2018 in Docker by Damon Salvatore
• 5,980 points
963 views
0 votes
1 answer

Different file owner inside Docker container and in host machine

Here is what you can try. Since ...READ MORE

answered Jun 27, 2018 in Docker by Atul
• 10,240 points
1,955 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,738 views
0 votes
2 answers
+2 votes
1 answer

How to link one running container with other running container in docker.

Hi @Yuvraj! Yes, this is possible. You can ...READ MORE

answered Dec 16, 2019 in Docker by Kalgi
• 52,350 points
2,228 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP