0
我有以下docker-compose.yml
::使用帶有泊塢窗,compose.yml docker_service模塊時,「類型錯誤不能對類字節對象使用字符串模式」
version: "3"
services:
container0:
image: myimage
build:
context: .
ports:
- "10000:22"
container1:
image: myimage
build:
context: .
ports:
- "10001:22"
container2:
image: myimage
build:
context: .
ports:
- "10002:22"
,並在我的劇本以下任務:
- name: setting up containers
docker_service:
project_src: .
files:
- docker-compose.yml
state: present
的docker-compose.yml
似乎是正確的,並沒有直接與docker-compose up
消耗時,它沒有錯誤。
但運行我的劇本的時候,我得到如下:
$ ansible-playbook -e 'ansible_python_interpreter=/usr/bin/python3' playbook.yml
PLAY [set up containers] **********************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************
ok: [localhost]
[...]
TASK [setting up containers] ***********************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Creating containers_container0_1 ... \r\nCreating containers_container2_1 ... \r\nCreating containers_container1_1 ... \r\n\u001b[1A\u001b[2K\rCreating containers_container0_1 ... \u001b[32mdone\u001b[0m\r\u001b[1B\u001b[1A\u001b[2K\rCreating containers_container2_1 ... \u001b[32mdone\u001b[0m\r\u001b[1B\u001b[1A\u001b[2K\rCreating containers_container1_1 ... \u001b[32mdone\u001b[0m\r\u001b[1BTraceback (most recent call last):\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 1016, in <module>\n main()\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 1011, in main\n result = ContainerManager(client).exec_module()\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 608, in exec_module\n result = self.cmd_up()\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 703, in cmd_up\n get_stdout(fd_name)\n File \"/tmp/ansible_hvp0_qgr/ansible_module_docker_service.py\", line 512, in get_stdout\n new_line = re.sub(r'\\x1b\\[.+m', '', line.encode('ascii'))\n File \"/usr/lib/python3.6/re.py\", line 191, in sub\n return _compile(pattern, flags).sub(repl, string, count)\nTypeError: cannot use a string pattern on a bytes-like object\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}
to retry, use: --limit @/home/vmonteco/Code/Perso/Ansible/containers/playbook.retry
PLAY RECAP *****************************************************************************************************************
localhost : ok=6 changed=0 unreachable=0 failed=1
什麼會導致這個錯誤?
儘管運行此命令後容器仍然成功創建並啓動。
從錯誤它似乎是一個可靠的模塊問題,而不是與碼頭相關。請與支持團隊聯繫 –
@TarunLalwani謝謝您的建議。我會按照你的建議進行。 – vmonteco