# Dockerfile
FROM python:3.9.13-slim-buster
WORKDIR /app
RUN echo "[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple/\n\n[install]\ntrusted-host = mirrors.aliyun.com" > /etc/pip.conf
COPY ./requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
#COPY . .
#
#CMD [ "python", "./your-daemon-or-script.py" ]
# docker build -t py2 .
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
$ docker run -v E:\www\python\py1\app:/app 3.9.13-slim-buster echo -e "[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple/" > /etc/pip.conf && pip install --no-cache-dir -r requirements.txt && python /app/main.py
$ docker run --name py1 -v E:/www/python/py1/site-packages:/usr/local/lib/python3.10/site-packages -v E:/www/python/py1/app:/app -w /app python:3.9.13-slim-buster python main.py
docker run -it python:3.9.13-slim-buster bash
docker run e:/www/pyWorkspace/py4/venv/Lib/site-packages:/usr/local/lib/python3.10/site-packages -v E:/www/python/py1/app:/app -w /app py1 python main.py
docker run -v E:/www/python/py1/app:/app -w /app py1 python main.py
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10