Docker链接到以前启动的容器
我想执行一个docker-compose run
,将运行一些以前启动的容器。 我的docker-compose.yml文件如下所示:
one_shot_service: ... links: - long_running_service:docker long_running_service: ...
我的工作stream程是:
- 启动长时间运行的服务
docker-compose up long_running_service
- 多次运行一次性服务。
docker-compose run --no-deps one_shot_service
当我这样做时, one_shot_service
上的/etc/hosts
文件不包含one_shot_service
条目。 当我没有--no-deps
时候运行就没有问题。 我不想没有long_running_service
的原因是因为long_running_service
需要很长时间才能启动。
长话短说,我如何链接到现有的容器?
您可以使用external_links
指令 。
例:
external_links: - long_running_service:your_alias