Dockerfile for development with gcc, intended for development in C and C++
Designed for development with Devcontainer or via CLI Docker commands to bind-mount source code.
- build-essential(gcc, g++, make, etc.)
- clangd
- gdb
- git
Note In addition, my dotfiles are included in the layers of the image.
Build image
docker build -t s3igo/gcc .
Run container
docker run --rm -it s3igo/gcc
Note In the following, the
$
prompt represents the host shell, the#
prompt represents the container shell, and the>
symbol represents the VS Code command palette.
-
Start container
$ docker compose -f example/compose.yaml run --rm gcc
-
Compile and run the C source code with gcc
# gcc hello.c -o hello && ./hello
-
Open the example project in VS Code
$ code example
-
Select
Reopen in Container
from the command palette
> Dev Containers: Reopen in Container
-
Open and run the VS Code terminal or use the Code Runner extension
# gcc hello.c -o hello && ./hello
or> Run Code
This method allows using the clang-format with VS Code's clangd extension or debugging with gdb.
The MIT license applies to the Dockerfile and other source code, but the tools and binaries included in the resulting docker image generated by the Dockerfile are subject to their respective licenses.