[英]Launch Docker Container using ansible-playbook from a locally available docker image
I have created a docker image with name revi-centos6. 我创建了一个名为revi-centos6的docker镜像。 (The image has not been pushed to the docker hub)
(映像尚未推送到docker hub)
Used the command as follows: 使用命令如下:
sudo docker build -t revi-centos6 .
The image got built successfully. 映像已成功构建。 Also ran
docker images
and found the newly created docker image in the list. 还运行了
docker images
并在列表中找到了新创建的docker镜像。
I have the following playbook contents (docker1.playbook): 我有以下剧本内容(docker1.playbook):
# Create a a docker container on localhost (this has an ssh server in the image)
- hosts: localhost
sudo: yes
tasks:
- name: start container
docker: image=revi-centos6 hostname=test name=test detach=False state=running
I then ran the following command: 然后,我运行以下命令:
ansible-playbook --ask-sudo-pass docker1.playbook -vvvv
However, I got the following error: 但是,出现以下错误:
failed: [localhost] => {"changes": ["{\\"status\\":\\"Pulling repository revi-centos6\\"}\\r\\n", "{\\"errorDetail\\":{\\"message\\":\\"Error: image library/revi-centos6:latest not found\\"},\\"error\\":\\"Error: image library/revi-centos6:latest not found\\"}\\r\\n"], "failed": true, "status": ""} msg: Unrecognized status from pull.
失败:[localhost] => {“ changes”:[“ {\\”状态\\“:\\”拉存储库revi-centos6 \\“} \\ r \\ n”,“ {\\” errorDetail \\“:{\\” message \\ “:\\”错误:图片库/ revi-centos6:最新找不到\\“},\\”错误\\“:\\”错误:图片库/ revi-centos6:最新找不到\\“} \\ r \\ n”], “失败”:true,“状态”:“”} msg:拉式状态无法识别。
Why isn't it picking the image that was built locally and trying to look up for it from the hub? 为什么不选择本地构建的图像并尝试从集线器中查找它? Does that mean every time I create a new docker image, I have to push it to the hub?
这是否意味着每次创建新的Docker映像时,都必须将其推送到集线器?
Note: Btw I did run sudo docker run -t revi-centos6
, and it is able to launch the container from the locally created docker image. 注意:顺便说一句,我确实运行了
sudo docker run -t revi-centos6
,它能够从本地创建的docker映像启动容器。 Problems seems to occurring only while using ansible-playbook
command with the docker module. 问题似乎仅在通过
ansible-playbook
模块使用ansible-playbook
命令时出现。
The issue here is with the docker-py
module which has had some update recently that will probe the hub for the image first. 此处的问题与
docker-py
模块有关,该模块最近进行了一些更新,它将首先检测映像的集线器。 docker-py
does not use the command-line tools, it uses its own implementation of the docker api and does things in its own way. docker-py
不使用命令行工具,它使用自己的docker api实现并以自己的方式执行操作。 Try running your own private registry. 尝试运行您自己的私人注册表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.