Buster Dockerfile Root

I am trying to get migrate from alpine to buster image. My dockerfile looks like

FROM astronomerinc/ap-airflow:1.10.6-buster-onbuild

# Register the version in alternatives
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1

# Set python 3 as the default python
RUN update-alternatives --set python /usr/bin/python3.7indent preformatted text by 4 spaces

My packages.yml looks like

python3-shapely
python3.7
python3.7-dev
python3.7-distutils

The error I am getting is

+ update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
update-alternatives: using /usr/bin/python3.7 to provide /usr/bin/python (python) in auto mode
update-alternatives: error: error creating symbolic link '/etc/alternatives/python.dpkg-tmp': Permission denied
The command '/bin/bash -o pipefail -e -u -x -c update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1' returned a non-zero code: 2
Error: command 'docker build -t datapipeline/airflow:latest failed: failed to execute cmd: exit status 2

This is a pretty old question now, but I fixed this by making sure to stick USER root in front of my custom install scripts. So in the example in the question above, this would look like:

FROM astronomerinc/ap-airflow:1.10.6-buster-onbuild

USER root 

# Register the version in alternatives
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1

1 Like