QtCreator Docker plugin
-
I read the changelog of QtCreator 5 and the docker plugin. I am very happy you are working on this!
However, I can't get it to work.
I am adding a new device docker image. Then you can click on 'Auto-detect Kit Items', but nothing is detected. I am 100% sure GCC is installed in the container (in /usr/bin/, it is an ubuntu container with some development tools installed), as well as cmake and gdb, but it is not found. Also, when clicking on 'List auto-Detected Kit Items', no items are listed. I can see the docker image is running, so that part works.
The 'Open Shell in Container' button is also not doing anything.So, when going back to 'kits', all compilers are on my host system and no compiler from within the docker container is listed. Same for the debugger.
So how can I get this to work?
(I currently have qtcreator installed inside the container and running it from the container with the X output to my host, but I prefer to run qtcreator on my host and just build and debug inside the container).
-
I've been trying to figure it out as well... no idea why there is a complete lack of hints anywhere. What I have figured out so far:
- Enable the plugin in Qt Creator
- Use docker pull to fetch a container image with your desired environment
- In the qt creator options dialog you can select the "Devices" side bar and "Add..." a "Docker Device" and "Start Wizard" - this will then list the images, one of which can be selected
- Back on the Devices tab in Options you can insert paths to mount (needed to avoid "The Docker device has not setup shared directories. This will not work for building." when setting up the kit. I think this needs to add the path that the current project needs for building (e.g. /home/bob, if your project is in /home/bob/my-docker-project and a shadow build dir is
/home/bob/build-my-docker-project-docker-image) - Click on the "Auto-detect Kit Items" button, which will run the image and query the tools available and generate a kit like "Docker Image 'user/image' (84749dfde023)". You should check the kit to confirm the settings it found: e.g. to tell it which C and C++ compiler to use.
- With the kit setup, you can now select the it as a build config in the Projects side bar.
The announcement says this only works with CMake projects, so I expect CMake to be required in the image. I expect the image also requires a C++ compiler and something like ninja.
Having said all that, I still can't get it building in the container... build generates an exe but it appears to be built using the host GCC (from greping the "strings" output for "GCC: (") rather than the older one on the image. I tried the "Open Shell in Container" option in the device tab which "docker ps" shows has started an instance but Qt Creator shows "Error starting remote shell" in the "General Messages". Running the executable does seem to use the container, as it complains about "GLIBC_2.34 not found", which isn't there when running it locally.
I sometimes get error messages like: Local read access to Docker container <long hex number> unavailable through directory "<no value>". Which seems to be a result of the IDE inspecting the container instance it created and looking for the MergedDir in the GraphDriver... this is beyond my simple docker knowledge but google suggests this is an attribute of the overlayfs in docker, whilst "docker info" indicates that my setup is using btrfs, but I've no idea how to switch it to overlay2 (or whatever it is expecting).
Would be nice if there is some info, even informal (a qtcreator bug / ticket?) as it feels like I am close, but missing some key step / requirement.
Steve.
-
@beeka Thank you for your explanation. I am doing the same steps, but when doing 'Auto-detect Kit Items', nothing is detected. I am already building in the container, so it has cmake, gcc and all other build tools that are needed.
I can indeed see a container is started, but I can not do anything with it. Exactly like you say.
I already tried the newest version of QtCreator, but that has the same problems.
-
@Maaike You can create your own kit, setting the docker device as the build + run target... so the auto-detect is only a nice-to-have (although you would expect it to work). However for me the build doesn't use the container.
It is frustrating, as this is a feature I have been wanting for a while. As it is, I don't know if I am running into bugs that should be reported or something not yet supported.
Steve.
PS: After writing my previous post, I noticed that the CMake output shows it has detected GCC 11, rather than the older version in the container, so I can tell it isn't working without grepping the binary.
-
thank you for the explanation above.
After I close QtCreator and re-open it the configured docker kits often disappear even in Docker daemon is running.I wonder how docker plugin detects the compilers and the Qt version inside the container? Do you know which commands it runs or the sources?
thank you
-
@enricopapi said in QtCreator Docker plugin:
After I close QtCreator and re-open it the configured docker kits often disappear even in Docker daemon is running.
It is actually working for me.
Well at all qtcreator developers working on this: I have to say it finally works with qtcreator 8! I am so happy, thanks a lot for making this work!
QtCreator did crash once while detecting all the files, but after restarting, it works like a charm. -
There are some Docker files in Creator's own repo: https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/tests/manual/docker