Getting error while building the docker image

Question:

I am trying to install the python 2 through my dockerfile but getting the following error.

Step 10/58 : RUN apt install python2
 ---> Running in d08c8eb21a67

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python2-minimal
  python2.7 python2.7-minimal
Suggested packages:
  python2-doc python-tk python2.7-doc binfmt-support
The following NEW packages will be installed:
  libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python2
  python2-minimal python2.7 python2.7-minimal
0 upgraded, 7 newly installed, 0 to remove and 8 not upgraded.
Need to get 3816 kB of archives.
After this operation, 16.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
The command '/bin/sh -c apt install python2' returned a non-zero code: 1

Here I am trying to install the python2 and some of my docker steps are given below.

Dockerfile:

FROM ubuntu:20.04


RUN apt-get update

# SET TZ
RUN apt-get install -y tzdata
RUN echo 'Asia/Kolkata' > /etc/timezone
RUN dpkg-reconfigure --frontend noninteractive tzdata

# System tools
RUN apt-get install -y --no-install-recommends libatlas-base-dev gfortran nginx supervisor
RUN apt install -y curl wget

# JAVA 11
RUN apt-get install -y openjdk-11-jdk

# BUILD tools
RUN apt-get install -y maven

# Python2

RUN apt install python2

# NodeJS
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs

In python2 installation steps the processing is existing with the above error. Can anybody help me to resolve the issue.

Asked By: subhra_user

||

Answers:

change from

RUN apt install python2

to

RUN apt install -y python2
Answered By: Yahro

As @anemyte suggests (in a comment on the question), use apt-get instead of just apt.

Answered By: Jerry K.
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.