web3
web3 copied to clipboard
"git": executable file not found in $PATH
I'm trying to follow the guide Generating Common Contracts using Docker image
docker run --rm \
-v ./web3-data:/data \
gochain/web3 \
generate contract erc20 --name "Test Tokens" --symbol TEST
But get the error
2024/05/17 09:29:12 Cloning OpenZeppelin v4.6.0...
ERROR: Cloning finished with error: exec: "git": executable file not found in $PATH
And we can check that git executable is missing in the Docker image
# Check sh
docker run -it --entrypoint /bin/sh gochain/web3 -c "which sh"
/bin/sh
# Check git
docker run -it --entrypoint /bin/sh gochain/web3 -c "which git"
# Check interactively
docker run -it --entrypoint /bin/sh gochain/web3
/app # which git
/app #
/app # git
/bin/sh: git: not found
Docker builds probably are done via Dockerfile, we can fix that by updating
- RUN apk add --no-cache ca-certificates
+ RUN apk add --no-cache ca-certificates git
We can use a wrapper Dockerfile as a workaround
FROM gochain/web3
RUN apk add --no-cache git
# Build
docker build -t web3-git .
# Size
docker images -a | grep web3
web3-git latest 0a9e9c666a5f 44 seconds ago 58MB
gochain/web3 latest 88dded04d5cb 5 months ago 42MB
# Check
docker run -it --entrypoint /bin/sh web3-git -c "which git"
/usr/bin/git
But there is an issue that web3 will clone repository into the local /app directory and will write contract in the same location. In that way we can't mount /app, unless we will copy web3 binary
# Copy binary
docker run --rm \
-v ./web3-data:/app-data \
--entrypoint /bin/sh \
web3-git \
-c "cp /app/web3 /app-data"
# Generate contract
docker run --rm \
-v ./web3-data:/app \
web3-git \
generate contract erc20 --name "Test Tokens" --symbol TEST
Looks like we can't build contract inside Docker image as we rely to Docker for that
docker run --rm \
-v ./web3-data:/app \
web3-git \
contract build TEST.sol
ERROR: Failed to compile "TEST_flatten.sol": solc: exec: "docker": executable file not found in $PATH
To run those commands inside docker, we'd have to have a docker-in-docker build, which we don't have.
Best to run it outside of docker if you can.
I'm not so familiar with that, but can we create Docker images with solidity compiller?
Ya, that's an option.