CLion + Docker + X11 forwarding


I'm running CLion 2021.3.3, to which I am very new.  I do all my development with Docker and am trying to stand up a new CMake project to create a simple 2D plot using  I want to build this project using the Docker toolchain (which I set up using instructions from here  I am able to build and run an exec built from the following:

#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;

int main() {
return 0;

using my run configuration that uses the Docker toolchain and a container derived from my Docker image, however, I don't see the expected plot window pop-up.

This seems like a really simple use case but I can't seem to find posts on SO or JB forums that address anything close to what I am trying to do.  In my homegrown setups, I would just launch a dev container using the following

docker run -it --rm \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    --name some-name \
    --net host \
    --privileged \

after configuring my interactive bash sessions with xhost +local:docker.  Then, I'd compile and run my application and I'd see the plot windows appear using my host's x11 server. 

Put simply: What's the best way to build and run applications that create graphics using CLion and the Docker toolchain?

Comment actions Permalink


In CLion 2022.1 EAP you can now provide additional container settings, such as port and volume bindings, and others -

Maybe it will be useful in your case.

Comment actions Permalink

Anna Falevskaya can confirm that the EAP gives me the desired configurability for the docker runtime.  Thanks for the tip!


Please sign in to leave a comment.