Cargo build works private git repo in deps but not from docker

My project has dependency to local/private git repo like below:
my_dependecny = { git = "https://my_git/my_dependency", branch = "my_branch" }
When I do "cargo build --release" from terminal it works fine.

git-fetch-with-cli = true

Now I want to create docker image for my app.

FROM rust:1.59.0
WORKDIR /my_app
COPY . .
RUN cargo build --release
ENTRYPOINT ["./target/release/my_app"]

But docker build --tag my_app --file Dockerfile . fails:

#9 2.135 Caused by:
#9 2.135   failed to authenticate when downloading repository
#9 2.135 
#9 2.135   * attempted to find username/password via git's `credential.helper` support, but failed
#9 2.135 
#9 2.135   if the git CLI succeeds then `net.git-fetch-with-cli` may help here
#9 2.135
#9 2.135 
#9 2.135 Caused by:
#9 2.135   failed to acquire username/password from local configuration

could anybody advice what was configured wrong?

You probably set up git to use your credentials at some point on your machine. The docker build doesn't have access to that so it's failing. You'll need to specify the credentials somehow in the docker container as well.