如何从docker-compose获取docker生成的ip端口

问题描述 投票:0回答:1

docker网络似乎无法正常工作,docker应该在指定容器名称时知道地址和端口,否则我会丢失什么?

是否有可能获得生成的IP端口,如:

docker-compose.yml

command: nsqd 
         --auth-http-address='host:docker inspect -f '{{(index 
         (index .NetworkSettings.Ports "80/tcp") 0).HostPort}}' some-image'

试图更改本地地址Im的--auth-http-address='0.0.0.0:80'在本地运行。

docker-compose.yml

services:
  service1:
    image: image_name
    command: nsqd --auth-http-address='authenticator'
  authenticator:
    image: some_image
    command: some server.py
    ports: - "80"
    container_name: authenticator

错误消息

错误:针对身份验证器地址身份验证器的身份验证失败:地址中缺少端口

docker docker-compose yaml docker-networking nsq
1个回答
0
投票

错误表明它也期望端口号。将docker-compose.yml中的命令更改为

 services:
  service1:
    image: image_name
    command: nsqd --auth-http-address=authenticator:80
© www.soinside.com 2019 - 2024. All rights reserved.