我需要启动一个具有多个端口映射的docker容器,如下所示:
- name: Run My container
docker_container:
name: "MyContainer"
image: "MyImage"
state: present
pull: true
restart_policy: always
published_ports:
- 1200:1200
- 1201:1201
- 1202:1202
- 1203:1203
.
.
.
- 1300:1300
我想要做的是将Ansible脚本运行为:
- name: Run My container
docker_container:
name: "MyContainer"
image: "MyImage"
state: present
pull: true
restart_policy: always
published_ports:
- 1200-1300:1200-1300
虽然,它不起作用,Ansible给我以下错误信息:
File \"/tmp/ansible_8zDYC9/ansible_module_docker_container.py\", line 987, in _parse_publish_ports\r\n container_port = int(parts[-1])\r\nValueError: invalid literal for int() with base 10: '1200-1300'
是否可以将主机和容器之间的多个端口映射到同一行?
PS:我使用的是Ansible 2.3
答案 0 :(得分:0)
我不确定我是否得出结论,但你需要用双引号设置端口,如下所示:
“1200-1300:1200-1300”