docker stack deploy use compose file can not specify ip:port

211 Views Asked by At
version: "3"

services:
  dhsearch:
    image: dhsearch
    ports:
      - "127.0.0.1:8001:80"
    deploy:
      replicas: 1

this is my docker-compose.yml and i use it to docker stack deploy

docker stack deploy -c docker-compose.yml dhsearch

but the ip is not work, below is the docker stack services dhsearch result

ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
uowjwv0uoo1g        dhsearch_dhsearch   replicated          1/1                 dhsearch            *:8001->80/tcp

the ports is *:8001->80/tcp instead of 127.0.0.1:8001->80/tcp

i want 127.0.0.1

1

There are 1 best solutions below

0
Chris On BEST ANSWER

You are using the default network created for the stack, which is an overlay network. The reason for the ip part of the mapping being dropped is that an overlay network has no support for the ip part. See this page for the supported mappings.

There is a bug report describing the exact same issue you're having: https://github.com/moby/moby/issues/32299

Unfortunately that issue has not yet been resolved.