我想在win10上使用clion进行远程Docker容器调试Ubuntu 18.04的Env(OpenCV 4),我将Docker安装在本地计算机(win10)中。 感谢https://github.com/shuhaoliu/docker-clion-dev,我使用了他的Dockerfile:
FROM ubuntu:bionic
########################################################
# Essential packages for remote debugging and login in
########################################################
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
apt-utils gcc g++ openssh-server cmake build-essential gdb gdbserver rsync vim
ADD . /code
WORKDIR /code
# Taken from - https://docs.docker.com/engine/examples/running_ssh_service/#environment-variables
RUN mkdir /var/run/sshd
RUN echo 'root:root' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
# 22 for ssh server. 7777 for gdb server.
EXPOSE 22 7777
RUN useradd -ms /bin/bash debugger
RUN echo 'debugger:pwd' | chpasswd
########################################################
# Add custom packages and development environment here
Install OpenCV4
########################################################
########################################################
CMD ["/usr/sbin/sshd","-D"]
和compose.yml:
version: '3'
services:
gdbserver:
build: .
security_opt: # options needed for gdb debugging
- seccomp:unconfined
- apparmor:unconfined
container_name: debug
ports:
- "7776:22"
- "7777:7777"
volumes:
- .:/code
它可以与许多C ++库一起很好地工作,但是我想使用OpenCV4库,我想运行这个CPP文件:
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc,char* argv[]) {
Mat src = imread("/code/001.png");
if (src.empty()) {
printf("cannot load images!\n");
return -1;
}
namedwindow("show_photo",WINDOW_AUTOSIZE);
imshow("show_photo",src);
return 0;
}
它表明: (显示图片:314):Gtk-WARNING警告**:09:56:09.309:无法打开显示:
我发现了一些信息,但是它们都是关于输入命令行,如何修改dockerfile和yml文件的信息? 请高手程序员帮帮我!
我的IDE是Win10上的Clion,我已经在win10上安装了Xming并且知道X0.hosts。