如何在守护进程模式下 运行 Python 和 docker?

How to run Python with docker on daemon mode?

从 Docker 中心获取 python:

$ docker pull python

在 CoreOS 上。

想使用 Ansible 从其他主机连接它,所以需要在 CoreOS 上启动 Python。

但是这样怎么做呢?


更多详情

这种方式可以运行 ansible with coreos:

第 1 步:在 CoreOS

上使用 shell 脚本安装 python

(据说不好,现在可以用了)

How do I run python on my Vagrant vm instance that is CoreOS?

第 2 步:在 ansible-playbook 中配置主机

[coreos]
core-01

[coreos:vars]
ansible_ssh_user=core
ansible_python_interpreter=/home/core/bin/python

第 3 步:测试连接

$ ansible -m ping -u core -i hosts core-01
core-01 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

可以使用。但是关于 Step 1,有没有办法使用 python 容器来启动它而不是使用 shell 脚本来安装?

即使您可以通过 ansible 连接到 python 容器,python 代码也会在容器内执行。所以它没有实际用途,除非你真的想使用 ansible 在容器内做一些事情。

在 coreos 中安装 python 的最佳方法是使用 ansible 的 raw 模块。

参考:

1). https://coreos.com/blog/managing-coreos-with-ansible.html
2). http://docs.ansible.com/ansible/latest/modules/raw_module.html