I want to run network mode as host for Redis cluster in docker.
The command to execute in the redis image of docker hub, is written as follows.
docker run --name some-redis -d redis
After performing port mapping by giving the -p option as follows:
docker run -p 6379:6379 --name some-redis redis
If you connect to redis-cli, the connection is good.
> redis-cli -p 6379
127.0.0.1:6379>
If you look at the network with docker container inspect some-redis, the default network mode is bridge.
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
I tried to proceed with the host.
docker run --net=host -p 6379:6379 --name some-redis redis
WARNING: Published ports are discarded when using host network mode
If a phrase such as, is displayed, the port is not disclosed.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6f4edb2c4f8a redis "docker-entrypoint.s…" 5 seconds ago Up 4 seconds some-redis
Of course, you can't even connect to redis-cli.
> redis-cli -p 6379
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
Docker container doesn't expose ports when --net=host is mentioned in the docker run command
Looking at the above question, it seems that the port should be automatically public.
How can I expose ports in network mode host in docker redis?
Check you machine, the --net=host
only works in linux.
https://docs.docker.com/network/host/
The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.