KevinWMatthews/gcc-cmake

Docker container with gcc and CMake.

★ 0Forks 0DockerfileGitHub ↗Compare

Project website ↗

README

gcc and CMake in Docker

CMake installed to the official gcc Docker image.

Tags and Dockerfile links

Images are tagged with gcc version first and CMake version second, so gcc8 with CMake 3.13.1 is tagged with 8-3.13.1:

These images are updated as changes to the Dockerfiles are made.

Additionally, images are tagged with a date stamp YYYYMMDD:

These images are built from tags in the source repo and are stable.

Here is a complete list of Docker tags.

Build In Container

For rapid development, bind mount your source and build directories to the container:

$ docker run \
    --rm -it \
    --user $(id --user):$(id --group) \
    --mount type=bind,src=/path/to/source/dir,dst=/usr/src/<source_dir> \
    --mount type=bind,src=/path/to/build/dir,dst=/usr/src/<build_dir> \
    --workdir /usr/src/<build_dir> \
    <image> \
    <command>

This will run the container, execute <command>, and exit the container.

Leave <command> blank to shell into the container.

Permissions

When mounting code to the container, it is advisable to run the container with current system user ID. If the container is run as root, all files that the container touches in the source and build directories will be owned by root.

This can be prevented with docker run's --user option. On Ubuntu Linux, use:

--user $(id --user):$(id --group)

or something similar.

Additional Resources

gcc Build Examples

Container Permissions

  • Blog post on using gosu in a Dockerfile to set container permissions.
    • The first comment provides an alternate solution: docker run -ti \ -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro \ -u $( id -u $USER ):$( id -g $USER ) \ some-image:lastest bash
  • Random GitHub repo. Untested.
  • Blog post using the nobody user's uid when launching the container.

Contributors

KevinWMatthews

Issues