For a small project, I want an application in a docker container to connect to the localhost of the machine. An answer to this question: From inside of a Docker container, how do I connect to the localhost of the machine? tells me the preferred way is to use --net="host"
in the docker run command.
I use a compose file to start the container. And this question told me the net
option was renamed to network_mode: "host"
.
Here is the beginning of the compose file
version: '3.6'
services:
shiny:
image: paulrougieux/eutradeflows
deploy:
restart_policy:
condition: on-failure
network_mode: "host"
ports:
- "3838:3838"
When I start this file
sudo docker stack deploy -c stackshiny.yml shiny
I get the error:
Ignoring unsupported options: network_mode
For information
$ sudo docker version
Client:
Version: 18.04.0-ce
Server:
Engine:
Version: 18.04.0-ce
How do I enable connection to a database on the host from a docker container?