For me the only problem in your Dockerfile is in the line RUN apt install python -y. This is erroring with Package 'python' has no installation candidate.
It is expected since python refers to version 2.x of Python wich is deprecated and no longer present in the default Ubuntu repositories.
Changing your Dockerfile to use Python version 3.x worked fine for me.
FROM ubuntu:latest
RUN apt update
RUN apt install python3 python3-pip -y
WORKDIR /Destop/DS
COPY requirement.txt ./
RUN pip3 install -r requirement.txt
COPY script2.py ./
CMD ["python3", "./script2.py"]
To test I used requirement.txt
pandas==1.5.1
and script2.py
import pandas as pd
print(pd.__version__)
With this building the docker image and running a container from it executed succesfully.
docker build -t myimage .
docker run --rm myimage
Answer from Matteo Zanoni on Stack OverflowVideos
You can read about the python image in its documentation
The interesting part is:
This tag is based off of buildpack-deps. buildpack-deps is designed for the average user of docker who has many images on their system. It, by design, has a large number of extremely common Debian packages.
And buildpack-deps itself can be based on either Debian, or Ubuntu image.
As they mention in the documentation - if you don't have specific requirements, or don't know why you'd not use another image, then python is a good choice.
In the future, you may be interested in other images if you for example want to have your deployment image smaller than the one testing with (which may have some extra tools). Or in general you could be tempted to use the smallest size possible to remove unnecessary utilities. There are reasons to do each of these - you'll likely figure out yourself at what point these matter to you.
Well, as viraptor says, Python is a good choice, but it weighs 900 MB
The size of the Python image - why 900MB?
https://github.com/docker-library/python/issues/30
There is a great blog post about the size of the docker images (in fact only the Python docker images) by Yasser Martinez
http://yasermartinez.com/blog/posts/creating-super-small-docker-images.html
Extract
Python itself is not small, a typical python installation needs close to 100 MB once uncompressed on the disk. Of course one could imagine that here are many files included that aren't needed in most of the usual cases (like the turtle module). Is it possible to create a smaller python docker image?
The answer is YES; if you now do a docker pull elyase/staticpython you will get a working python image with only 8.5 MB in size.
See also the github of João Ferreira Loff
https://github.com/jfloff/alpine-python
Extract
REPOSITORY TAG SIZE
jfloff/alpine-python 2.7-slim 52.86 MB
python 2.7-slim 180.8 MB
jfloff/alpine-python 2.7 234.2 MB
python 2.7 676.2 MB
jfloff/alpine-python 3.4-slim 110.4 MB
python 3.4-slim 193.9 MB
jfloff/alpine-python 3.4 280 MB
python 3.4 681.5 MB
jfloff/alpine-python latest 248.8 MB
python 3.5 685.4 MB
jfloff/alpine-python latest-slim 79.11 MB
python 3.5-slim 197.8 MB