简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM