Do not install Rust, Solana and Anchor on the developer machine. You only need to install Docker.
npm install -g solana-test-validator-docker
In order to mount a docker volume, a .solrc
configuration file needs to be created in the folder you want to be mounted.
{
"imageName": "tchambard/solana-test-validator:latest",
"containerName": "solana-test-validator"
}
The following command will create it.
solana-docker-shell init
Start the container. The directory where this command is executed must be somewhere in the project directory containing .solrc
file
solana-docker-shell start
solana-docker-shell stop
When starting the container, three volumes are mounted:
-
solana-docker:/opt Every tools needed are installed in
/opt
and mounted to named volumesolana-docker
. This volume makes rust/cargo installations and builds caches persistent. -
solana-docker-cache:/home/node/.cache Some solana caches are stored in user home directory
/home/node/.cache
and mounted to named volumesolana-docker-cache
. This volume makes solana caches persistent. -
${.solrc_directory}:/working_dir When running
solana-docker-shell init
, a configuration file.solrc
is created. The directory containing this file is mounted to/working_dir
.
solana-docker-shell exec "solana-test-validator --ledger /opt/.config/solana/.ledger -r --bind-address 0.0.0.0 --rpc-port 8899"
solana-docker-shell exec "anchor --version"
solana-docker-shell exec "anchor build"
solana-docker-shell exec "cargo --version"
solana-docker-shell exec "yarn --version"
solana-docker-shell exec "solana --version"
solana-docker-shell exec "solana balance"
solana-docker-shell exec "solana airdrop 2"
...
But simplier, you can also use directly these commands:
# Launch solana-test-validator. Any options of classic command solana-test-validator are supported...
solana-test-validator-docker --ledger /opt/.config/solana/.ledger -r --bind-address 0.0.0.0 --rpc-port 8899
# Use anchor
anchor-docker --version
anchor-docker build
...
# or cargo
cargo-docker --version
cargo-docker build
...
# or yarn
yarn-docker --version
yarn-docker install
...
# or solana
solana-docker --version
solana-docker balance
solana-docker airdrop 2
...