Run GitHub Linguist Inside Docker Container on Linux

Run GitHub Linguist Inside Docker Container on Linux

GitHub Linguist is a utility used to identify programming languages within a repository and calculate the percentage of code written in each language. It powers language statistics on GitHub and can be useful for analyzing project composition, auditing repositories, or generating language breakdown reports. Running GitHub Linguist from a Docker container eliminates the need to install Ruby and other dependencies directly on the host system while ensuring a consistent execution environment.

To demonstrate usage, clone the repository and switch to its directory:

git clone https://github.com/github-linguist/linguist && cd linguist

To analyze the repository using GitHub Linguist inside a container, run:

docker run -it --rm -v ./:/repo crazymax/linguist

Command details:

  • docker run - starts a new container instance.
  • -it - enables an interactive terminal session.
  • --rm - removes the container once the process finishes.
  • -v ./:/repo - mounts the current repository into the container at /repo.
  • crazymax/linguist - specifies the Docker image that includes GitHub Linguist.

When the command completes, GitHub Linguist scans the repository contents and displays a language distribution summary similar to the following:

70.11%  325181     Ruby
20.97%  97265      C
6.02%   27904      Go
1.50%   6948       Lex
1.13%   5248       Shell
0.27%   1268       Dockerfile

The report provides a quick overview of the technologies used within the project, making it useful for repository analysis, audits, and language distribution tracking.

Leave a Comment

Cancel reply

Your email address will not be published.