如何使用 golang 作为基础镜像在 docker 中安装 python3?

moh*_*adi 5 python docker docker-compose

我的 docker 文件看起来像这样:

# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang

# Install our Go dependencies
RUN go get -u golang.org/x/oauth2...
ENTRYPOINT /go/bin/...
Run Code Online (Sandbox Code Playgroud)

我的基本应用程序将在 golang 上运行,但我需要从 golang 访问 python 脚本进行一些处理。如何在 docker 容器中安装 python3 并使用 pip 安装一些 python 依赖项。

小智 0

如果您确实使用像这样的 Debian 映像:

https://github.com/docker-library/golang/blob/cffcff7fce7f6b6b5c82fc8f7b3331a10590a661/1.9/stretch/Dockerfile

哪个是标签:golang:1.9-stretch

Debian Stretch 已经附带了 python3 https://wiki.debian.org/Python

因此无需采取进一步行动。但是,您需要安装 pip,然后正常继续。

  • 我已经尝试过这个图像。`python3` 产生 `/bin/sh: 1: python3: not find` (4认同)