内容

FROM debian:9
RUN sed -i 's@http://deb.debian.org@http://mirrors.aliyun.com@g' /etc/apt/sources.list
RUN sed -i 's@http://security.debian.org@http://mirrors.aliyun.com@g' /etc/apt/sources.list
RUN apt update
RUN apt install -y python3
RUN apt install -y python3-*pyqt5*
RUN apt install -y python3-pip
RUN apt install -y clang
RUN apt install -y git
RUN apt install -y libgcc1*
RUN apt install -y python3-dev*
RUN apt install -y zlib1g-dev 
RUN apt clean all
RUN pip3 install pymysql==0.8.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip3 install zmail==0.2.8  -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip3 install nuitka==1.0.7  -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip3 install urllib3==1.26.9  -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip3 install requests==2.25.1  -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip3 install pyinstaller==3.6.0 setuptools==30.1.0  -i https://pypi.tuna.tsinghua.edu.cn/simple
ENV PATH $PATH:`echo ~`/.local/bin
CMD ["/bin/bash"]

制作效果

[root@bxy1 py]#  docker build -t debian9/python3.5:2.0 .
Sending build context to Docker daemon   2.56kB
Step 1/20 : FROM debian:9
 ---> 7e6281878e38
Step 2/20 : RUN sed -i 's@http://deb.debian.org@http://mirrors.aliyun.com@g' /etc/apt/sources.list
 ---> Using cache
 ---> 107b218a7152
Step 3/20 : RUN apt update
 ---> Using cache
 ---> 47cc92cc6d45
Step 4/20 : RUN apt install -y python3
 ---> Using cache
 ---> 795b32eb7c27
Step 5/20 : RUN apt install -y python3-*pyqt5*
 ---> Using cache
 ---> 4aa09e9801eb
Step 6/20 : RUN apt install -y python3-pip
 ---> Using cache
 ---> e3b063ae078f
Step 7/20 : RUN apt install -y clang
 ---> Using cache
 ---> 2e71a4ee9e30
Step 8/20 : RUN apt install -y git
 ---> Using cache
 ---> 26a09be29f2d
Step 9/20 : RUN apt install -y libgcc1*
 ---> Using cache
 ---> 170ded1c7b8f
Step 10/20 : RUN apt install -y python3-dev*
 ---> Using cache
 ---> 7eaa96bb22b8
Step 11/20 : RUN apt install -y zlib1g-dev
 ---> Using cache
 ---> c974e2b0689e
Step 12/20 : RUN apt clean all
 ---> Using cache
 ---> f30b9df0c87c
Step 13/20 : RUN pip3 install pymysql==0.8.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
 ---> Using cache
 ---> 28d92890bdf2
Step 14/20 : RUN pip3 install zmail==0.2.8  -i https://pypi.tuna.tsinghua.edu.cn/simple
 ---> Using cache
 ---> bddcc471933f
Step 15/20 : RUN pip3 install nuitka==1.0.7  -i https://pypi.tuna.tsinghua.edu.cn/simple
 ---> Using cache
 ---> 9580be20eb32
Step 16/20 : RUN pip3 install urllib3==1.26.9  -i https://pypi.tuna.tsinghua.edu.cn/simple
 ---> Using cache
 ---> 2e64feb1735f
Step 17/20 : RUN pip3 install requests==2.25.1  -i https://pypi.tuna.tsinghua.edu.cn/simple
 ---> Using cache
 ---> fc015c45ea8b
Step 18/20 : RUN pip3 install pyinstaller==3.6.0 setuptools==30.1.0  -i https://pypi.tuna.tsinghua.edu.cn/simple
 ---> Using cache
 ---> 27146baad5d9
Step 19/20 : ENV PATH $PATH:`echo ~`/.local/bin
 ---> Using cache
 ---> 064f588ea52b
Step 20/20 : CMD ["/bin/bash"]
 ---> Using cache
 ---> 6dd2f7bcd6ac
Successfully built 6dd2f7bcd6ac
Successfully tagged debian9/python3.5:2.0

运行容器

[root@bxy1 py]# docker run -tid --net=host --name py  debian9/python3.5:2.0 /bin/bash
1288a7f06146018b8f25799a587a47a523075b5a979fb87bf680bab9cb1d4379
[root@bxy1 py]# docker ps -a
CONTAINER ID        IMAGE                                        COMMAND                  CREATED             STATUS                        PORTS                NAMES
1288a7f06146        debian9/python3.5:2.0                        "/bin/bash"              3 seconds ago       Up 2 seconds                                       py
d8975e26794d        2e64feb1735f                                 "/bin/sh -c 'pip3 in…"   9 minutes ago       Exited (1) 9 minutes ago                           wonderful_kare
074adba71655        170ded1c7b8f                                 "/bin/sh -c 'apt ins…"   10 minutes ago      Exited (100) 10 minutes ago                        affectionate_hertz
836bc091010f        170ded1c7b8f                                 "/bin/sh -c 'apt ins…"   10 minutes ago      Exited (100) 10 minutes ago                        dreamy_cartwright
bd6a62a68651        160c8914ea24                                 "/bin/sh -c 'pip3 in…"   17 minutes ago      Exited (1) 17 minutes ago                          jovial_matsumoto
1ce7996f6e18        d60aae31fa98                                 "/bin/sh -c 'pip3 in…"   18 minutes ago      Exited (1) 18 minutes ago                          dreamy_neumann
8eb8600a3f36        65f687969837                                 "/bin/sh -c 'pip3 co…"   20 minutes ago      Exited (1) 20 minutes ago                          confident_blackburn
11577c5a049d        65f687969837                                 "/bin/sh -c 'pip3 co…"   43 minutes ago      Exited (1) 43 minutes ago                          cranky_nightingale
fa03b405bcfd        debian:10                                    "/bin/bash"              2 hours ago         Up 2 hours                                         ftp_rw
0410eced34b4        rustdesk/rustdesk-server-s6:latest-arm64v8   "/init"                  5 weeks ago         Up 5 weeks (healthy)                               rustdesk-server
3e6a578558de        nginx                                        "/docker-entrypoint.…"   2 months ago        Up 4 weeks                                         nginx
b6fa51e2eb09        debian10/halo:1.5.4                          "/bin/bash"              2 months ago        Up 2 months                                        halo-latest
f972aeff6dde        halo:1.5.3                                   "/bin/bash"              3 months ago        Exited (0) 2 months ago                            halo
d01dd2629fb0        6cad6600c076                                 "/bin/sh -c 'apt upd…"   5 months ago        Exited (100) 5 months ago                          vibrant_diffie
26b213551ba2        mariadb                                      "docker-entrypoint.s…"   8 months ago        Up 12 days                                         mariadb
bfd9c5f9618e        http-file:1.1                                "bash"                   10 months ago       Up 2 months                   0.0.0.0:81->80/tcp   file
[root@bxy1 py]# docker exec -ti py bash
root@bxy1:/# pyinstaller 
usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME]
                   [--add-data <SRC;DEST or SRC:DEST>]
                   [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR]
                   [--hidden-import MODULENAME]
                   [--additional-hooks-dir HOOKSPATH]
                   [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
                   [--key KEY] [-d {all,imports,bootloader,noarchive}] [-s]
                   [--noupx] [--upx-exclude FILE] [-c] [-w]
                   [-i <FILE.ico or FILE.exe,ID or FILE.icns>]
                   [--version-file FILE] [-m <FILE or XML>] [-r RESOURCE]
                   [--uac-admin] [--uac-uiaccess] [--win-private-assemblies]
                   [--win-no-prefer-redirects]
                   [--osx-bundle-identifier BUNDLE_IDENTIFIER]
                   [--runtime-tmpdir PATH] [--bootloader-ignore-signals]
                   [--distpath DIR] [--workpath WORKPATH] [-y]
                   [--upx-dir UPX_DIR] [-a] [--clean] [--log-level LEVEL]
                   scriptname [scriptname ...]
pyinstaller: error: the following arguments are required: scriptname
root@bxy1:/# exit