【发布时间】:2020-06-17 19:05:28
【问题描述】:
这就是我的 docker 文件的样子
version: "3"
services:
controller:
build: ./cd_controller
image: cd_controller:latest
env_file: $PWD/robot-configurations/.env
cap_add:
- ALL
links:
- test_fixture
volumes:
- dependencypackages:/root/dependency-packages
- robotconfigurations:/root/robot-configurations
container_name: controller_g5
test_fixture:
image: docker-standard-all.ur-update.dk/ur/pytest-ur:0.7.1
volumes:
- pytestfixture:/workspace
- controllertests:/workspace/controller-tests
entrypoint: /workspace/entrypoint.sh
container_name: test_fixture
stdin_open: true # docker run -i
tty: true # docker run -t
volumes:
robotconfigurations:
driver_opts:
type: none
device: $PWD/robot-configurations
o: bind
...
基本上它有两个两个服务/容器控制器和test_fixture。控制器正在运行源代码,并且 test_fixture 包含所有 test_cases。 test_fixture 需要通过套接字与控制器通信。由于 docker-compose 在其容器之间创建了一个网络,因此在我的 py 测试用例中,我只是使用
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("controller_g5", 30001)) # controller_g5 is name of the controller container
到目前为止,一切看起来都很好。但我意识到我有多个版本/功能的源代码。所以我想创建一个相同事物的多个实例,每个实例都有自己的网络。命名容器是否会阻止在不同网络中创建具有相同名称的容器?此外,我不确定如何在同一台主机上使用类似的容器再启动一个网络。我遇到了Multiple isolated environments on a single host 但无法获得示例。
非常感谢任何帮助。
【问题讨论】:
标签: linux docker docker-compose continuous-integration