I am trying to execute a “docker-compose up” command. Please find below my docker-compose file. I tried with network_mode: “host” but it doesn’t work. I am on Linux OS. request you to let me know if I am making any blunder.
version: '3.6' services: mongo: image: "mongo:latest" container_name: ohif-mongo ports: - "27017:27017" viewer: image: ohif/viewer:latest container_name: ohif-viewer ports: - "3030:3000" network_mode: "host" # please make note of the alignment links: - mongo environment: - MONGO_URL=mongodb://mongo:27017/ohif extra_hosts: - "pacsIP:172.xx.xxx.xxx" volumes: - ./dockersupport-app.json:/app/app.json
after execution, I get the below error
ERROR: for 8f4c3de7e3a3_ohif-viewer Cannot create container for service viewer: conflicting options: host type networking can't be used with links. This would result in undefined behavior ERROR: for viewer Cannot create container for service viewer: conflicting options: host type networking can't be used with links. This would result in undefined behavior
I don’t know why the error message is displayed twice. Not sure whether this is expected
Second, when I change the alignment of network_mode: “host” (by 1/2 spaces)
ports: - "3030:3000" network_mode: "host" # please see the change in alignment now links: - mongo
I get the below error message
ERROR: yaml.parser.ParserError: while parsing a block mapping in "./docker-compose.yml", line 10, column 5 expected <block end>, but found '<block mapping start>' in "./docker-compose.yml", line 14, column 6
How can I start the container with network=host mode?