Windows10: ERROR: peer0.org1.example.com Cannot create container for service peer0.org1.example.com: mkdir C:Program FilesGitvar: Access is denied

Solution for Windows10: ERROR: peer0.org1.example.com Cannot create container for service peer0.org1.example.com: mkdir C:Program FilesGitvar: Access is denied
is Given Below:

I’m trying to start fabric test-network from fabric-samples (version 2.3) with command ./network.sh up createChannel -c mychannel -ca.

and when generating CCP files for Org1 and Org2 I get the following error:

Generating CCP files for Org1 and Org2
Found orphan containers (ca_org1, ca_orderer, ca_org2) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Creating peer0.org2.example.com ...
Creating peer0.org1.example.com ...
Creating orderer.example.com    ...
Creating peer0.org1.example.com ... error

ERROR: for peer0.org1.example.com  Cannot create container for service peer0.org1.example.com: mkdir C:Program FilesGitvar: Access is denied.
Creating peer0.org2.example.com ... error

ERROR: for peer0.org2.example.com  Cannot create container for service peer0.org2.example.com: mkdir C:Program FilesGitvar: Access is denied.
Creating orderer.example.com    ... done

ERROR: for peer0.org1.example.com  Cannot create container for service peer0.org1.example.com: mkdir C:Program FilesGitvar: Access is denied.

ERROR: for peer0.org2.example.com  Cannot create container for service peer0.org2.example.com: mkdir C:Program FilesGitvar: Access is denied.
Encountered errors while bringing up the project.
Docker Compose is now in the Docker CLI, try `docker compose up`

CONTAINER ID   IMAGE                               COMMAND                  CREATED          STATUS                  PORTS                                                                                                                                 NAMES
88feeed7fab3   hyperledger/fabric-orderer:latest   "orderer"                3 seconds ago    Up Less than a second   0.0.0.0:7050->7050/tcp, :::7050->7050/tcp, 0.0.0.0:7053->7053/tcp, :::7053->7053/tcp, 0.0.0.0:17050->17050/tcp, :::17050->17050/tcp   orderer.example.com
627fa71a0361   hyperledger/fabric-ca:latest        "sh -c 'fabric-ca-se…"   24 seconds ago   Up 21 seconds           0.0.0.0:7054->7054/tcp, :::7054->7054/tcp, 0.0.0.0:17054->17054/tcp, :::17054->17054/tcp                                              ca_org1
0bbf5d51ec2a   hyperledger/fabric-ca:latest        "sh -c 'fabric-ca-se…"   24 seconds ago   Up 21 seconds           0.0.0.0:8054->8054/tcp, :::8054->8054/tcp, 7054/tcp, 0.0.0.0:18054->18054/tcp, :::18054->18054/tcp                                    ca_org2
5b07405d8546   hyperledger/fabric-ca:latest        "sh -c 'fabric-ca-se…"   24 seconds ago   Up 21 seconds           0.0.0.0:9054->9054/tcp, :::9054->9054/tcp, 7054/tcp, 0.0.0.0:19054->19054/tcp, :::19054->19054/tcp  

                              ca_orderer

And then when channel is created I get this error:

Channel 'mychannel' created
Joining org1 peer to the channel...
Using organization 1
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=1
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=1
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=1
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=1
Error: error getting endorser client for channel: endorser client failed to connect to localhost:7051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp [::1]:7051: connectex: No connection could be made because the target machine actively refused it."
After 5 attempts, peer0.org1 has failed to join channel 'mychannel'

Does anyone know how to solve this beacuse this is not the first time that I’m starting the fabric network, and everything worked fine before. I’m guessing this has something to do with docker. I already tried to stop the containers (docker ps -aq | xargs docker kill), and delete them (docker ps -aq | xargs docker rm) but I’t didn’t work.

docker version:

Client:
 Cloud integration: 1.0.14
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.16.3
 Git commit:        370c289
 Built:             Fri Apr  9 22:49:36 2021
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:44:56 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

This seems to be a Docker on Windows mounting issue. Try setting ‘MSYS_NO_PATHCONV’ to 1, e.g. add to the beginning of the ‘test_network/network.sh’ script:

export MSYS_NO_PATHCONV=1

See here and the references inside.

p.s. I suggest editing the question title and adding environment info like OS, shell and docker versions.

p.s2 Until corrected, we better submit this fix to the fabric-samples repo.