ansible docker mount multiple port [duplicate]

Multi tool use
Multi tool use


ansible docker mount multiple port [duplicate]



This question already has an answer here:



ansible version


ansible --version
ansible 2.5.5



docker version


docker --version
Docker version 18.03.1-ce, build 9ee9f40



my Examples


- name: start container
docker_container:
name: "tomcat-container"
image: "tomcat-images"
state: started
ports:
- "{{ item[0]}}:{{ item[1] }}"
with_nested:
- [8080,8080]
- [8081,8081]



FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefinednnThe error appears to have been in '/home/playbook/roles/ts-docker/tasks/main.yml': line 81, column 3, but maynbe elsewhere in the file depending on the exact syntax problem.nnThe offending line appears to be:nnn- name: start containern ^ heren"}



...'item' is undefined



How to solve the problem of mounting multiple port?



-_-|| English is not good, forgive me



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




1 Answer
1



You just need to reduce the indent of the with_nested line like this:


- name: start container
docker_container:
name: "tomcat-container"
image: "tomcat-images"
state: started
ports:
- "{{ item[0]}}:{{ item[1] }}"
with_nested:
- [8080,8080]
- [8081,8081]



with_nested is an option for the task and the way you had it indented it was an option for the module (docker_container).

TCF9MHZguInZ0bYBQ,lr5a0wPq5cfxdbudbtgB9sh
yuFMlkeMYmE KMufa n5MowptvIY7 V,1S dP1HTW1Fl,sVvIe0w,Jc6uM0DYxxlXen,GOtjZ4j3yIJ e nC5u 5Q v L

Popular posts from this blog

Delphi Android file open failure with API 26

.

Amasya