1

When I run cloc inside a docker container, it does not seem to recursively search through the given directories, compared to running it stand-alone.

Dockerfile:

FROM python:3.6.2-alpine3.6

VOLUME "/data"
WORKDIR /data

RUN apk --no-cache add cloc=1.72-r2

Running cloc without the docker container I get the following:

cloc src\main\java\ --by-file --unix --report-file=temp.csv
      19 text files.
      19 unique files.
      12 files ignored.
Wrote temp.csv

When running it with the docker container the following happens:

docker run --rm -it -v C:\repos\code-repository\:/data cloc-image cloc src/main/java --by-file --unix --report-file=/data/temp2.csv
       0 text files.
       0 unique files.
       2 files ignored.

Any ideas? I have:

  • Checked the rights of the user in the docker container (root).
  • Using ash I checked inside the container if the volume was correctly mapped, and all files were present.
  • Checked if the version of cloc inside the container was indeed the same as the local installation (both 1.72).

EDIT 1:

Interesting finding, this behaviour only shows on Windows, the same Dockerfile/container works fine on a linux machine.

Oromë
  • 199
  • 2
  • 16
  • You might `docker run ... cloc-image ls -l` and `... pwd` to get a little more context. – David Maze Aug 20 '18 at 11:37
  • I did david, the working directory is, as expected, /data. All files are owned by root and `whoami` shows the user as root as well. – Oromë Aug 20 '18 at 12:23

1 Answers1

1

I encountered the same problem on a debian:stretch-based container running on Docker for Windows, where the volume cloc was running against was a local directory. The solution was to add --follow-links to cloc:

$ cloc .

# Only returned results of top-level directory

Fix:

$ cloc --follow-links .

# Included nested files
mopsled
  • 8,445
  • 1
  • 38
  • 40