Skip to content

This is a great repo which works fine in docker containers

Notifications You must be signed in to change notification settings

ilhangrn/cpp_tutorials

 
 

Repository files navigation

Build status build workflow alt text

This repository contains my C++ snippets code on C++ concepts/ idioms, optimized C++, modern C++ and advance C++. I have included snippets and samples code for using third party libs for parsing CSV, YAML and JASON files. Example of code benchmarking with Google Benchmark is available. There is also a tutorial on using CMake for building and exporting your project.

Building and Installation

1. Building the Image

There is docker file for this project where contains all dependencies and you build the image with :

docker build -t cpp_tutorials .

ig_notes: it is done. Now i have a image named cpp_tutorials.

2. Creating the container

Create a container where you mount the checkout code into your container:

docker run --name <continer-name> -v <checked-out-path-on-host>:<path-in-the-container> -it <docker-image-name>

for instance:

docker run --name cpp_container -v /home/behnam/workspace/cpp_tutorials:/cpp_tutorials -it cpp_tutorials

ig_notes: i will apply it like below:

docker run --name cpp_container -v C:\Users\ilhan.goren\IG_OnePiece\_IG_DOCKER\cpp_tutorials:/cpp_tutorials -it cpp_tutorials

ig_notes:The 3. step is for the container you have. In next time i will call just the 3. command.

3. Starting an existing container

If you have already created a container from the docker image, you can start it with:

docker start -i cpp_container

After getting run the container we go to the vscode and attach the container over docker extention. Like i do now. I am changing the readme inside container over vscode. Lets see the commit from my PC powershell.

git diff says:

+> After getting run the container we go to the vscode and attach the container over docker extention. Like i do now. I am changing the readme inside container over vscode. Lets see the commit from my PC powershell.

4. Removing unnecessary images and containers

You can remove unnecessary images and containers by:

docker image prune -a

docker container prune

GUI application with docker

  1. You need to run:

docker run --name cpp_container -v /home/behnam/workspace/cpp_tutorials:/cpp_tutorials --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" -it cpp_tutorials

  1. On the host run the following (every time you run your container):

export containerId=$(docker ps -l -q)

xhost +local: docker inspect --format='{{ .Config.Hostname }}' $containerId

read more here

About

This is a great repo which works fine in docker containers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.0%
  • CMake 1.7%
  • Other 0.3%