{"id":13442950,"url":"https://github.com/shuhaoliu/docker-clion-dev","last_synced_at":"2025-07-28T05:36:05.406Z","repository":{"id":54183104,"uuid":"141071724","full_name":"shuhaoliu/docker-clion-dev","owner":"shuhaoliu","description":"Debugging C++ in a Docker Container with CLion IDE","archived":false,"fork":false,"pushed_at":"2023-04-17T18:47:26.000Z","size":358,"stargazers_count":221,"open_issues_count":6,"forks_count":49,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-10T01:15:53.240Z","etag":null,"topics":["clion","clion-ide","cpp","debug","docker","docker-container","dockerfile","gdb","ide","remote-debug"],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shuhaoliu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-07-16T01:26:25.000Z","updated_at":"2025-03-06T07:18:36.000Z","dependencies_parsed_at":"2024-04-13T15:17:13.723Z","dependency_job_id":"5e6eeaf0-49b7-4cae-9cfc-554f4a114a20","html_url":"https://github.com/shuhaoliu/docker-clion-dev","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuhaoliu%2Fdocker-clion-dev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuhaoliu%2Fdocker-clion-dev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuhaoliu%2Fdocker-clion-dev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuhaoliu%2Fdocker-clion-dev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuhaoliu","download_url":"https://codeload.github.com/shuhaoliu/docker-clion-dev/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137891,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clion","clion-ide","cpp","debug","docker","docker-container","dockerfile","gdb","ide","remote-debug"],"created_at":"2024-07-31T03:01:53.734Z","updated_at":"2025-04-10T01:16:00.652Z","avatar_url":"https://github.com/shuhaoliu.png","language":"Dockerfile","funding_links":[],"categories":["Dockerfile"],"sub_categories":[],"readme":"# Debugging C++ in a Docker Container with CLion\n\n\u003e Note: Source code is modified from [Cornell CS 5450 course material](\nhttps://pages.github.coecis.cornell.edu/cs5450/website/assignments/p1/docker.html).\n\n\u003e **Update December 2018:** this repository has been updated after the Clion 2018.3 release, which adds native remote debugging support.\nCheck out the [official guide](https://blog.jetbrains.com/clion/2018/09/initial-remote-dev-support-clion/) It makes a debugger's life much easier. HOORAY!\n\nThis repository provides a minimal C++ project setup and the Dockerfile that\nallows developers to debug code in a Docker container using JetBrain Clion IDE.\n\nDebugging in a container has many benefits, especially if you are developing\nLinux applications on OS X.\n\n+ It allows a consistent environment for both development and deployment;\n+ Developers are free from installing dependencies on their development\nmachine. Some packages cannot be easily installed on OS X.\n+ The container can be launched on your development machine, or on a remote server.\n\n## Introduction\n\nAll application code, as well as its dependencies, will be installed, compiled, and ran within the container.\nThen, we launch a `gdbserver` to allow remote debugging outside of the container.\n\nClion supports remote debugging feature since [2018.3](https://blog.jetbrains.com/clion/2018/09/initial-remote-dev-support-clion/).\n\nThe container has a long running ssh server process, such that the container can\nbe placed on a remote host.\n\n\u003e The container exposes 2 ports. 7777 is for `gdbserver` connection. 22 for the\nssh server. To avoid trouble when the container is launched on the development\nmachine, the container 22 port is mapped to host 7776 port. This can be changed\nto any arbitrary number in `docker-compose.yml`.\n\n## Prerequisites\n\nOn your development machine, you must have a CLion IDE (2018.3 or above) installed,\n\nOn the host machine of your container (which can be the development machine),\nthe latest Docker CE installation would be sufficient.\n\n## Usage\n\nTo debug the example, follow the following steps. If you have any problem, please refer to the [official tutorial](https://blog.jetbrains.com/clion/2018/09/initial-remote-dev-support-clion/) before opening an issue.\n\n0. Import the project into CLion using the provided `CMakeLists.txt`.\n\n0. Build the container.\n\n    ```bash\n    docker build -t liuempire/docker_clion_dev .\n    ```\n\n0. Launch the container with `docker-compose`.\n\n    ```bash\n    docker-compose up -d\n    ```\n    After this step, the container is running with an ssh server daemon. Clion will automatically run/test/debug via an ssh connection. The folder where `docker-compose.yml` locates will be the mapped to `/home/debugger/code` within the container. CLion will *not* use this mapped directory.\n\n0. Configure the container toolchain in Clion. Go to ***Settings/Preferences | Build, Execution, Deployment | Toolchains***, configure the container as a remote host. The username is `debugger`. The password is `pwd`. The completed configurations should be similar to the following: ![Toolchain configuration](configs/toolchain-config.png)\n\n0. Configure the container CMake settings in CLion. Go to ***Settings/Preferences | Build, Execution, Deployment | CMake***, add a container CMake profile:![CMake configuration](configs/cmake-config.png)\n\n0. Check the file mapping settings in Clion. Before each run, code will be `rsync`-ed to the container at a temporary location. The following configuration should be generated automatically after the previous two steps:![Deployment configuration](configs/deployment-auto-config.png)\n\n0. In your Clion, you should be able to select `Debug-Local container` in before execution.\n\n0. Add breakpoints in Clion. Happy debugging!\n\nTo stop the container, run `docker-compose down`.\n\n## Customization\n\n+ Add dependency installation scripts to `Dockerfile`.\n+ Replace `CMakeLists.txt` with your customized project `CMakeLists.txt`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuhaoliu%2Fdocker-clion-dev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuhaoliu%2Fdocker-clion-dev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuhaoliu%2Fdocker-clion-dev/lists"}