How to run a Docker Container in a Host Network Mode – HellGeeks
Home » Docker
How to run a Docker Container in a Host Network Mode
Docker
How to run a Docker Container in a Host Network Mode
0
Save
Saved
Removed
0
By using a docker compose, you can run a Docker container in a host network mode by defining network mode in a docker-compose file. With this configuration the docker container would run on the host network and utilise the host network port which would get exposed and defined during docker build.
And keep in mind the you don’t have to provide any ports in docker-compose file in a host network mode, otherwise it would generate an error. Here’s an example docker-compose file
version: "3.7"
services:
example-service:
image: example-image
network_mode: "host"
restart: always
environment:
- TZ=Australia/Melbourne
volumes:
- example-image-data1883:/data
volumes:
example-image-data1883:
5/5 – (1 vote)