如何在 windows docker 容器中安装 python 和 ansible

我的 windows 10 机器上安装了 windows docker。现在我需要在我的 docker 容器中安装 python 和 ansible。

我很少参考在 Linux 机器上安装 python 和 ansible。但我找不到如何在 windows10 docker 容器中安装 python 3 和 ansible 的来源。

安装 python 后,我可以尝试使用pip命令安装 ansible。但为此,我不确定如何首先安装 python。在 docker 中,我已经安装了 Jenkins,并且想在 Jenkins 中运行我的 ansible 剧本。请帮忙。谢谢!


大话西游666
浏览 320回答 2
2回答

撒科打诨

您可以尝试使用已经安装了相同的现有 docker 映像,而不是自己安装在容器中。如果你还想自己构建,可以查看 github repo 中的 Dockerfile。https://hub.docker.com/r/zeeshanjamal16/ansibledocker

犯罪嫌疑人X

我构建了一个ansible定期跟踪devel分支的图像:# syntax=docker/dockerfile:experimentalFROM ubuntu:18.04ENV DEBIAN_FRONTEND noninteractiveENV PATH /ansible/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binRUN apt-get update && \    apt-get -y install \        git \        openssh-client \        python3.7 \        python3.7-dev \        python3-pip \        python3-setuptools \        python3-pygit2 \        build-essential \        libssl-dev \        libffi-dev \        manRUN groupadd -g 1000 ansible && \    useradd -u 1000 -g ansible -d /home/ansible -m -k /etc/skel -s /bin/bash ansibleRUN mkdir -p -m 0600 ~/.ssh && \    ssh-keyscan github.com >> ~/.ssh/known_hostsRUN --mount=type=ssh git clone -b devel https://github.com/ansible/ansible.git /ansible && \    chown -R 1000:1000 /ansibleRUN python3 -m pip install -r /ansible/requirements.txtRUN ln -s /usr/bin/python3 /usr/bin/pythonRUN echo '. /ansible/hacking/env-setup' >> /home/ansible/.bashrcENTRYPOINT ["/ansible/bin/ansible"]注意:ansible不打算从 Windows 控制服务器运行- 您可以在 Windows 上使用 Linux 容器此示例使用docker 构建增强功能镜像是按照 开发模块的通用环境设置配置的ansible构建镜像:DOCKER_BUILDKIT=1 docker build --rm --network host -t so:5776957 .运行容器:docker run --rm --network host -e ANSIBLE_HOME=/ansible -e PYTHONPATH=/ansible/lib so:5776957 localhost -m ping
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python