Skip to content

Docker Container and Newer Git Enforce Safe Directory Checks #1600

@aj-stein-nist

Description

@aj-stein-nist

Describe the bug

When doing local development, any script script in the that runs in the docker container or one built and run from said Dockerfile will often have differing file ownership on the host relative to inside the container. This will lead to errors like those in the replication section.

To work around this, you would need to re-run that command within the container every recreation of a container instance from an image, so it would be best to patch that in the Dockerfile itself. Because of how volume mounts work, and a volume mount is always owned by root, this is inevitable and ought to be fixed as this feature of git is now in all stable releases for a little bit. We will trust the volume mount.

More info and context on StackOverflow and other blogs, I cannot find an official man page source from git that I can link to from an Internet-routable URL unforunately.

Who is the bug affecting

NIST OSCAL developers who intend to make use of our public Dockerfile spec.

What is affected by this bug

CI/CD, Tooling & API

How do we replicate this issue

  1. Check out the repo.
  2. `pushd /path/to/repo/oscal/
  3. pushd docs
  4. docker compose up -d docs

Observe the error below when the run-server.sh or other scripts would run, a similar error would occurs.

$ docker run -it -p 1313:1313 -v $(pwd):/oscal docs-docs
root@a711f12a02f5:/oscal# /oscal/docs/run-server.sh 

Generating XML and JSON Model Documentation
===========================================
fatal: detected dubious ownership in repository at '/oscal'
To add an exception for this directory, call:

        git config --global --add safe.directory /oscal
fatal: detected dubious ownership in repository at '/oscal'
To add an exception for this directory, call:

        git config --global --add safe.directory /oscal
BRANCH(initial)=''
fatal: detected dubious ownership in repository at '/oscal'
To add an exception for this directory, call:

        git config --global --add safe.directory /oscal
Name and URL for remote not detected, using default
Unrecognized branch: 
BRANCH=''
VERSION='develop'
REVISION='develop'
TYPE='branch'
Generating index page failed for revision 'develop' on branch ''.
ERROR 2023/01/05 19:48:28 Failed to read Git log: fatal: detected dubious ownership in repository at '/oscal'
To add an exception for this directory, call:

        git config --global --add safe.directory /oscal
Error: logged 1 error(s)

Expected behavior (i.e. solution)

The entrypoint executes without error.

Other comments

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions