简体   繁体   中英

docker-compose run does not set links

I have a docker-compose.yml file along the lines of:

analytics:
    build: .
    links:
    - mongo:mongo
    ports:
    - 80:80
mongo:
    build: docker_containers/mongo
    expose:
    - 27017

Running docker-compose up creates a link in /etc/hosts to the mongo service. However, running docker-compose run analytics bash does not create the link -- I checked the /etc/hosts file.

The docs of docker-compose do not mention anything about this, so I'm confused.

  1. Why isn't the link set when using run ?
  2. How can I achieve this?

My take on the answers:

  1. It's a bug.
  2. See if it's fixed in an unreleased version of docker-compose or create an issue asking that the bug be fixed .

我只回答问题编号2.使用docker-compose run启动整个环境,然后在分析容器中执行docker exec

docker exec -ti $analytics_container_id bash

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