Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 2.7 reaches End of Life in 2 months #13

seanw2020 opened this issue Oct 28, 2019 · 3 comments

python 2.7 reaches End of Life in 2 months #13

seanw2020 opened this issue Oct 28, 2019 · 3 comments


Copy link

@seanw2020 seanw2020 commented Oct 28, 2019

First, thank you for this image! Second, could you update it, or create a new tag, for a python3 variant? For example, when I build your Dockerfile here, I see this output:

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop su
pport for Python 2.7. More details about Python 2 support in pip, can be found at

I managed to get python 3 installed in Alpine 3.10 by following this Dockerfile, but adding your suggested mitogen, ansible-lint, and pywinrm packages:

    pip3 install --no-cache mitogen ansible-lint ; \
    pip3 install --no-cache --upgrade pywinrm ; \

Final working version:

FROM alpine:latest

# LABEL maintainer="Johannes Denninger"
# Details:
# This is mostly Johannes' work, but with Will Hall's 2 modifcations and bash, git, jq and delete __pycache__, .pyc
# and no or su-exec. See

RUN set -euxo pipefail ;\
    sed -i 's/http\:\/\/\:\/\/' /etc/apk/repositories ;\
    apk add --no-cache --update python3 ca-certificates openssh-client sshpass dumb-init bash git jq ;\
    apk add --no-cache --update --virtual .build-deps python3-dev build-base libffi-dev openssl-dev ;\

    pip3 install --no-cache --upgrade pip ;\
    pip3 install --no-cache --upgrade setuptools ansible ;\
    pip3 install --no-cache mitogen ansible-lint ; \
    pip3 install --no-cache --upgrade pywinrm ; \
    apk del --no-cache --purge .build-deps ;\
    rm -rf /var/cache/apk/* ;\
    rm -rf /root/.cache ;\
    ln -s /usr/bin/python3 /usr/bin/python ;\
    mkdir -p /etc/ansible/ ;\
    /bin/echo -e "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts ;\
    ssh-keygen -q -t ed25519 -N '' -f /root/.ssh/id_ed25519 ;\
    mkdir -p ~/.ssh && echo "Host *" > ~/.ssh/config && echo " StrictHostKeyChecking no" >> ~/.ssh/config ;\
    adduser -s /bin/ash -u 1000 -D -h /ansible ansible

COPY ./ /usr/local/bin
RUN chmod +x /usr/local/bin/

# Details:
RUN find . -regex '^.*\(__pycache__\|\.py[co]\)$' -delete

ENTRYPOINT ["/usr/bin/dumb-init","--"]

USER ansible
WORKDIR /ansible


$ docker exec -ti app_ansible_1 python --version
Python 3.7.5


Copy link

@willhallonline willhallonline commented Oct 30, 2019

So this all works? Do you want to submit a PR to the Alpine 3.10? Or would you like me to do it?

Secondly, what would you prefer? To run a separate Python 3 version, or to just say "Python 2 is deprecated, use Python 3". What is your preference?

Copy link

@willhallonline willhallonline commented Nov 5, 2019

So, I bounced this issue onto LinkedIn too ( and it appears that people are in favour of deprecation of Python2 and replacing with Python3.

I will look for how best to easily do this. @seanw2020 Thanks again for bringing it to my attention. 👍 🥇

Copy link

@Jean-Baptiste-Lasselle Jean-Baptiste-Lasselle commented Mar 5, 2020

idea : integrating in docker builds, to manage python installation ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

3 participants