I'm trying to set up a container with two networks with docker-compose. I would like one of those networks to be the host network (ie: as if I was running docker run --net=host) and the other a user-defined network.
I tried this:
version: '3'
networks:
test:
driver: bridge
host:
external: true
services:
helloworld:
image: python:3.6-alpine
networks:
- test
- host
cap_add:
- NET_ADMIN
- NET_RAW
ports:
- 0.0.0.0:8080:8080
command: sh -c "cd /tmp && python -m http.server 8080"
I'm getting this error:
$ docker-compose up
Removing blah_helloworld_1
Starting 8743618e8af4_blah_helloworld_1 ... error
ERROR: for 8743618e8af4_blah_helloworld_1 network-scoped alias is supported only for containers in user defined networks
ERROR: for helloworld network-scoped alias is supported only for containers in user defined networks
ERROR: Encountered errors while bringing up the project.
network_modeproperty in the service. This is mutually exclusive with thenetworksproperty though. If you use thenetwork_mode: "host"your service has access to thetestnetwork, without explicitly joining. What exactly do you want to accomplish?testnetwork ifnetwork_mode: "host"is enabled?