Technology Sharing

Use Docker to create a Python project image

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

A collection of Docker desktop versions: If the system prompts that the new version is not supported, you can download the old version
I also share it below.
Link: https://pan.baidu.com/s/1HvaO2wOIE3pNE0bM7Qm3sA?pwd=g7ky Extraction code: g7ky
–Shared from Baidu Netdisk Super Member v2
Source reference: https://zhuanlan.zhihu.com/p/659528332

After downloading and installing, find daemon.json
insert image description here
Open and modify the mirror source. I use https://6kx4zyno.mirror.aliyuncs.com
insert image description here
Restart docker. Enter docker info in cmd. You can check the image source.insert image description here
No, the modification was successful.

Pull the required Python version image in the pycharm control platform docker pull python:3.9
Writing Dockerfile script

FROM python:3.9

WORKDIR /flaskProject

COPY requirements.txt .

COPY ./src ./src

RUN pip install -r requirements.txt

CMD ["python","./src/app.py"]

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

Build Python image

docker build -t name .
  • 1
docker run -p 8000:8000
  • 1