赞
踩
编写一个简单的pyqt5界面App.py
import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout class MyWindow(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): # 创建标签 label = QLabel('PyQt5界面', self) label.move(50, 50) # 创建按钮 button = QPushButton('点击', self) button.move(50, 100) button.clicked.connect(self.buttonClicked) # 创建布局 vbox = QVBoxLayout() vbox.addWidget(label) vbox.addWidget(button) # 将布局应用到窗口 self.setLayout(vbox) # 设置窗口大小和标题 self.setGeometry(300, 300, 300, 200) self.setWindowTitle('PyQt5界面') self.show() def buttonClicked(self): # 按钮点击事件 print('按钮被点击') if __name__ == '__main__': app = QApplication(sys.argv) window = MyWindow() sys.exit(app.exec_())
再次基础上运行Dockerfile脚本
FROM yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda:1.0.0 USER root RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 'A4B469963BF863CC' RUN apt-get update ENV TIME_ZONE Asia/Shanghai ENV DEBIAN_FRONTEND=noninteractive ENV LIBGL_ALWAYS_INDIRECT=1 RUN apt-get install ffmpeg -y RUN apt-get install libgl1-mesa-glx -y RUN apt-get install libxss1 -y RUN apt-get install libappindicator1 -y RUN apt-get install libindicator7 -y RUN apt-get install libjpeg8-dev -y RUN apt-get install libpng-dev -y RUN apt-get install libtiff5-dev -y RUN apt-get install zlib1g-dev -y RUN apt-get install libleptonica-dev -y RUN apt-get install libtesseract-dev -y RUN apt-get install tesseract-ocr -y RUN apt-get install fonts-liberation -y RUN apt-get install libappindicator3-1 -y RUN apt-get install libasound2 -y RUN apt-get install libnspr4 -y RUN apt-get install libnss3 -y RUN apt-get install xdg-utils -y RUN apt-get install libcanberra-gtk-module -y RUN apt-get install tcl-dev -y RUN apt-get install tk-dev -y RUN apt-get install python3-tk -y RUN apt-get install dbus -y RUN apt-get install locales -y RUN apt-get install ttf-wqy-microhei -y RUN apt-get install language-pack-zh-hans -y RUN apt-get install python3-pyqt5 -y ENV PATH /root/anaconda3/bin:$PATH RUN conda update conda -y RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ RUN conda config --set show_channel_urls yes RUN conda create -n ai-sport python=3.8 numpy pandas -y SHELL ["conda", "run", "-n", "ai-sport", "/bin/bash", "-c"] RUN pip install PyQt5 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com COPY . . #sudo docker build -t='yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda-qt5:1.0.0' . #xhost local:root #sudo docker run --net=host --name ai-sport-app --gpus '"device=0"' --privileged --rm -it -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -u root yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda-qt5:1.0.0
构建镜像
sudo docker build -t='yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda-qt5:1.0.0' .
给权限
xhost local:root
运行容器
sudo docker run --net=host --name ai-sport-app --gpus '"device=0"' --privileged --rm -it -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -u root yutianchi/11.2.1-cudnn8-runtime-ubuntu18.04-conda-qt5:1.0.0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。