Running docker-compose throws error "docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings
dockerizemyapp opened this issue · comments
Issue Description:
Running skydive using docker-compose method throws error "docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings"
Env:
-Tested on Linux Mint 20.2
cat /etc/*release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=20.2
DISTRIB_CODENAME=uma
DISTRIB_DESCRIPTION="Linux Mint 20.2 Uma"
NAME="Linux Mint"
VERSION="20.2 (Uma)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 20.2"
VERSION_ID="20.2"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=uma
UBUNTU_CODENAME=focal
-Docker and docker compose version:
docker --version
Docker version 20.10.8, build 3967b7d
docker-compose --version
docker-compose version 1.29.2, build 5becea4c
Steps to replicate issue:
-Followed documentation using the docker-compose method
curl -o docker-compose.yml https://raw.githubusercontent.com/skydive-project/skydive/master/contrib/docker/docker-compose.yml
-Running docker-compose throws error "docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings"
-Below are logs for reference:
docker-compose up
Creating skydive_elasticsearch_1 ... done
Creating skydive_skydive-analyzer_1 ... done
Creating skydive_skydive-agent_1 ...
ERROR: for skydive_skydive-agent_1 "host" network_mode is incompatible with port_bindings
ERROR: for skydive-agent "host" network_mode is incompatible with port_bindings
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose/cli/main.py", line 81, in main
File "compose/cli/main.py", line 203, in perform_command
File "compose/metrics/decorator.py", line 18, in wrapper
File "compose/cli/main.py", line 1186, in up
File "compose/cli/main.py", line 1182, in up
File "compose/project.py", line 702, in up
File "compose/parallel.py", line 108, in parallel_execute
File "compose/parallel.py", line 206, in producer
File "compose/project.py", line 688, in do
File "compose/service.py", line 564, in execute_convergence_plan
File "compose/service.py", line 480, in _execute_convergence_create
File "compose/parallel.py", line 108, in parallel_execute
File "compose/parallel.py", line 206, in producer
File "compose/service.py", line 478, in <lambda>
File "compose/service.py", line 457, in create_and_start
File "compose/service.py", line 334, in create_container
File "compose/service.py", line 941, in _get_container_create_options
File "compose/service.py", line 1073, in _get_container_host_config
File "docker/api/container.py", line 598, in create_host_config
File "docker/types/containers.py", line 339, in __init__
docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings
[819582] Failed to execute script docker-compose
-Below is the docker-compose file:
version: '2'
services:
elasticsearch:
image: elasticsearch:5
ports:
- "19200:9200"
- "19300:9300"
environment:
- "discovery.type=single-node"
networks:
- skynet
skydive-analyzer:
image: skydive/skydive
ports:
- "8082:8082"
- "8082:8082/udp"
links:
- elasticsearch
command: analyzer --listen=0.0.0.0:8082
environment:
- SKYDIVE_STORAGE_ELASTICSEARCH_HOST=elasticsearch:9200
- SKYDIVE_ANALYZER_STORAGE_BACKEND=elasticsearch
- SKYDIVE_GRAPH_BACKEND=elasticsearch
- SKYDIVE_ETCD_LISTEN=0.0.0.0:12379
networks:
- skynet
skydive-agent:
image: skydive/skydive
depends_on:
- skydive-analyzer
ports:
- "8081:8081"
network_mode: "host"
pid: "host"
command: agent --listen=0.0.0.0:8081
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/run/netns:/host/run
- /var/run/openvswitch/db.sock:/var/run/openvswitch/db.sock
environment:
- SKYDIVE_AGENT_TOPOLOGY_NETNS_RUN_PATH=/host/run
- SKYDIVE_ANALYZERS=127.0.0.1:8082
networks:
-From above, it does have "network_mode" as "host" along with "ports" defined.
@dockerizemyapp Thanks for reporting the issue. I pushed this PR #2403 to fix it. Could you please give it a try by any chance ?
@lebauce
-With the below compose file (latest fix), its working. Thanks for fixing the issue.
version: '2'
services:
elasticsearch:
image: elasticsearch:5
ports:
- "19200:9200"
- "19300:9300"
environment:
- "discovery.type=single-node"
networks:
- skynet
skydive-analyzer:
image: skydive/skydive
ports:
- "8082:8082"
- "8082:8082/udp"
links:
- elasticsearch
command: analyzer --listen=0.0.0.0:8082
environment:
- SKYDIVE_STORAGE_ELASTICSEARCH_HOST=elasticsearch:9200
- SKYDIVE_ANALYZER_STORAGE_BACKEND=elasticsearch
- SKYDIVE_GRAPH_BACKEND=elasticsearch
- SKYDIVE_ETCD_LISTEN=0.0.0.0:12379
networks:
- skynet
skydive-agent:
image: skydive/skydive
depends_on:
- skydive-analyzer
network_mode: "host"
pid: "host"
command: agent --listen=0.0.0.0:8081
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/run/netns:/host/run
- /var/run/openvswitch/db.sock:/var/run/openvswitch/db.sock
environment:
- SKYDIVE_AGENT_TOPOLOGY_NETNS_RUN_PATH=/host/run
- SKYDIVE_ANALYZERS=127.0.0.1:8082
networks:
skynet: