Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python dockerfile

# Dockerfile, Image, Container
# Container with python version 3.10
FROM python:3.10

# Add python file and directory
ADD main.py .

# upgrade pip and install pip packages
RUN pip install --no-cache-dir --upgrade pip && 
    pip install --no-cache-dir numpy 
    # Note: we had to merge the two "pip install" package lists here, otherwise
    # the last "pip install" command in the OP may break dependency resolution...

# run python program
CMD ["python", "main.py"]
Comment

docker install python dockerfile

# Python
FROM ubuntu:18.04

ARG PYTHON_VERSION=3.9.1
ENV DEBIAN_FRONTEND=noninteractive
ENV PATH $PATH:/usr/local/bin

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=aptcache1804 --mount=type=cache,target=/var/lib/apt,sharing=locked,id=aptcache1804 
    export DEBIAN_FRONTEND=noninteractive 
    && apt-get update -y 
    && apt-get install -y apt-utils sudo wget tar 

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=aptcache1804 --mount=type=cache,target=/var/lib/apt,sharing=locked,id=aptcache1804 
    export DEBIAN_FRONTEND=noninteractive 
    && apt-get update -y 
    && apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev

RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz 
    && tar -xf Python-${PYTHON_VERSION}.tgz
  
RUN cd Python-${PYTHON_VERSION} 
    && ls -la 
    && ./configure --enable-optimizations 
    && make -j 4 
    && make altinstall
    
RUN pip3 install requests asyncio

COPY ./entrypoint.py ./entrypoint.py

ENTRYPOINT python ./entrypoint.py
Comment

install python in dockerfile

RUN apt-get update
RUN apt-get install python
Comment

PREVIOUS NEXT
Code Example
Python :: python extract specific columns from pandas dataframe 
Python :: print python path variable 
Python :: python float to string n decimals 
Python :: python web3 to wei 
Python :: isinstance numpy array 
Python :: sort python dictionary by date 
Python :: fraction thesis 
Python :: python get int from string 
Python :: numpy test code 
Python :: python r2 score 
Python :: how to count stopwords in df 
Python :: df shift one column 
Python :: interpoltaion search formula python 
Python :: python day from datetime 
Python :: close turtle window python 
Python :: find index of null values pandas 
Python :: save dataframe to csv without index 
Python :: brownie get active network 
Python :: jupyter plot not showing 
Python :: remove unicode from string python 
Python :: python find the factors of a number 
Python :: normalize column pandas 
Python :: python format only 1 decimal place 
Python :: python nCr n choose r function 
Python :: how to read input from stdin in python 
Python :: wxpython make window stay on top 
Python :: how to check sklearn version 
Python :: matplotlib plot data 
Python :: python append to file 
Python :: matplotlib plot dpi 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =