Home > Net >  Docker: python has no installation candidate
Docker: python has no installation candidate

Time:10-02

I am trying to create a docker image from my docker file which has the following content:

FROM ubuntu:latest 
WORKDIR /app 
ADD . /app 
RUN apt-get update && apt-get install python -y 
CMD python /app/main.py 
LABEL color=red

which fails with the following error:

apt-get update && apt-get install python -y returned a non-zero code: 100 Error

So please help me in solving this error

CodePudding user response:

Docker is just Linux. When some apt-get install acme fails, you just need to try the exact command and or research the missing dependencies.

To replicate your error I ran: docker run -it ubuntu:latest and inside, I ran your apt-get update && apt-get install python -y. I got the error:

enter image description here

So, I tried with apt-get install python3 -y and it worked. Finally your Dockerfile should be:

FROM ubuntu:latest 
WORKDIR /app 
ADD . /app 
RUN apt-get update && apt-get install python3 -y 
CMD python3 /app/main.py 
LABEL color=red

Older Python

If your code needs old python version, you should not use FROM ubuntu:latest because in the lastest version of ubuntu, only python3 is allowed.

Anyway if you need python2, you must research a lot on internet to get the exact steps to install python2 or use some ready to use docker images:

CodePudding user response:

You should post all the output because maybe for some reason you use different apt sources than the official once.

However you need to give automatic consent to install:

apt-get install -y python

otherwise the command is waiting for you to approve.

  • Related