Shiva
Shiva

Reputation: 2002

docker not able to locate the file

I am getting error while trying execute below command

 docker run --rm -v /home/docker:/build ethereum/solc:stable /build/TransactionFee.sol --bin --abi --optimize -o /build

Error is

"/Users/amidala/projects/TransactionFee.sol" is not found.

The file is already exists:

amidalas-MacBook-Pro:projects amidala$ ls -ltr build/ docker/ TransactionFee.sol
-rwxr-xr-x  1 amidala  staff  730 Dec 10 23:46 TransactionFee.sol

docker/:

build/:
amidalas-MacBook-Pro:projects amidala$ docker run --rm -v /Users/amidala/projects/docker:/Users/amidala/projects/build ethereum/solc:stable /Users/amidala/projects/TransactionFee.sol --bin --abi --optimize -o /Users/amidala/projects/build
"/Users/amidala/projects/TransactionFee.sol" is not found.
amidalas-MacBook-Pro:projects amidala$ 

As you can see the file exists

enter image description here

/users already shared

enter image description here

Am I missing anything?

I am following the article Intro to Blockchain

Upvotes: 1

Views: 528

Answers (2)

michalhosna
michalhosna

Reputation: 8133

In you command:

docker run --rm \
    -v /User/amidala/projects/docker:/Users/amidala/projects/build \
    etherun/solc:stable \
    /User/amidala/projects/TransactionFee.sol \
    --bin --abi --optimize -o /Users/amidala/projects/build

You telling docker to mount your local folder /User/amidala/projects/docker to containers folder /Users/amidala/projects/build (That's the -v argument). So in the folder /Users/amidala/projects inside the container is only the docker folder and nothing more. No TransactionFee.sol file.

You probably want to mount /User/amidala/projects folder to containers /User/amidala/projects. So the whole projects folder is avabile for container.

docker run --rm \
    -v /User/amidala/projects:/User/amidala/projects \
    etherun/solc:stable \
    /User/amidala/projects/TransactionFee.sol \
    --bin --abi --optimize -o /Users/amidala/projects/build

PS: Using the same folder structure in container as io the host is good for simplicity, but not good for being sure to which folder you are referring.

There whole docker docs page about volumes and mounting: https://docs.docker.com/storage/volumes/

Upvotes: 2

Paulo Pedroso
Paulo Pedroso

Reputation: 3685

Michal Hošna's answer is accurate. But I would keep the container folder structure as is. Try running:

docker run --rm -v /Users/amidala/projects/docker:/build ethereum/solc:stable /build/TransactionFee.sol --bin --abi --optimize -o /build

Maybe the container is expecting things to happen within the build folder and you might get other errors when running your build.

Upvotes: 1

Related Questions