简体   繁体   中英

How do I install python3 in docker with golang as my base image?

My docker file looks something like this:

# 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/...

My base application will be running on golang,but I need to access a python script from golang for some processing. How do I install python3 in my docker container and install some of python dependencies using pip .

If you're indeed using a debian image like this one:

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

Which is tag: golang:1.9-stretch

Debian stretch comes with python3 already https://wiki.debian.org/Python

So no further action is required. You would need to install pip however and then continue as normal.

You can install python3 on official golang docker image by adding following lines to your Dockerfile:

RUN apt-get update
RUN apt-get -y install python3
RUN apt-get -y install python3-setuptools
RUN apt-get -y install python3-pip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM