Sign inSign up

simen39/python

By simen39

Updated over 1 year ago

Python is currently the most widely used programming language.

Image
Languages & frameworks
0

88

simen39/python repository overview

Introduction

Python is a high-level, general-purpose, interpreted programming language with a concise and readable syntax suitable for a variety of programming scenarios.

How to use

Run

  • usage:

    docker run -itd --restart=always --name $container simen39/python:$tag python your_script.py
    
  • example:

    docker run -itd --restart=always -v --name python_project1 simen39/python:3.9.7 python main.py
    

Create a Dockerfile for your Python project

#-设置 Python 基础镜像

FROM python:3.x.x

#-设置工作目录

WORKDIR /mqtt

#-更新 apt 和 apt-get

RUN apt-get update && apt-get upgrade -y

RUN apt update && apt upgrade -y

#-安装常用命令:vim、netstat、telnet

RUN apt install -y vim net-tools iputils-ping telnet git && apt clean

#-设置别名(例如:ll -> ls -l)

RUN echo "alias ll='ls -l'" >> ~/.bashrc

#-设置时区为 Asia/Shanghai

ENV TZ=Asia/Shanghai

#-安装时区数据包并设置时区

RUN apt-get update && apt-get install -y tzdata && ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && apt-get clean

#-更新 pip 到最新版本

RUN pip install --upgrade pip

#-复制本地的 requirements.txt 文件到容器中的 /app 目录(将依赖单独放到前面拷贝到容器里,这样在下次构建时可利用镜像缓存加速构建)

COPY conf/requirements.txt .

#-安装 requirements.txt 中列出的所有依赖

RUN pip install -r requirements.txt

#-复制你的应用代码到容器中的 /app 目录

COPY . .

#-设置容器启动时执行的命令(可在启动容器时修改)

CMD ["python", "./your-project-main-script.py"]

Tag summary

Content type

Image

Digest

sha256:3ece41be5

Size

365.1 MB

Last updated

over 1 year ago

docker pull simen39/python:3.13.1