简体   繁体   English

从本地可用的Docker映像中使用ansible-playbook启动Docker容器

[英]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.

相关问题 使用ansible-playbook安装docker-compose时出错 - Error when installing docker-compose using ansible-playbook 如何在 docker 容器上运行 ansible-playbook 以在 AWS EC2 Ubuntu 实例上执行命令? - How can I run ansible-playbook on docker container to execute commands on an AWS EC2 Ubuntu instance? 如何加载下载的图像,通过 ansible playbook 在 docker 容器中运行它 - How to load a downloaded image, run it in a docker container through an ansible playbook 使用 ansible playbook 在 docker 容器内运行 mvn clean install - Running mvn clean install inside docker container using ansible playbook 从Docker容器运行Ansible Playbook并在主机上部署 - Run ansible playbook from docker container and deploy on host machine 如何使用Ansible Playbook将Nginx Docker容器安装到主机中? - how to mount the nginx docker container into host using Ansible Playbook? 在 Jenkins 容器中运行 ansible-playbook - Run ansible-playbook in Jenkins container Docker容器和Ansible Playbook有什么区别? - What is the difference between a Docker Container and an Ansible Playbook? 将Ansible Playbook复制文件到Docker容器 - ansible playbook copy file to docker container 无法通过docker容器执行ansible playbook - Cannot execute ansible playbook via docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM