You can get any version of the compiler for any supported platform from solc-bin. The compiler is a single statically compiled binary so there's really not much point in running it via Docker unless you just really like that as a way to easily download it. The binary is the only file inside the docker image anyway.
To download and run 0.6.x:
curl -OL https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.6.12+commit.27d51765
chmod +x solc-linux-amd64-v0.6.12+commit.27d51765
./solc-linux-amd64-v0.6.12+commit.27d51765 --userdoc --devdoc myContract.sol
import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol", you also need to make sure that the compiler can find that file. In 0.8.8+ you can install chainlink via npm and simply add
--include-path node_modules/ to the
solc command. That option was not available on 0.6.x and the workaround is to create a symlink to it inside your project directory
ln -s node_modules/@chainlink/ @chainlink
or, alternatively, use import remapping (note however that remapping affects contract metadata):
./solc-linux-amd64-v0.6.12+commit.27d51765 @chainlink/=node_modules/@chainlink/ --userdoc --devdoc myContract.sol
When I install
solc on my ubuntu machine with
sudo snap install solc it installs some (the wrong) version and I don't see how I can change the install version or switch between versions.
The snap package is maintained by the community on the best-effort basis and is unfortunately out of date right now (#11940). I'd really recommend to use the static binary instead.
When I use the docker images
sudo docker run -v $HOME/myProject/contracts:/contracts ethereum/solc:0.6.12 -o /contracts/output --abi --bin /contracts/myContract.sol I get the error:
Error: Source "@chainlink/contracts/src/v0.6/ChainlinkClient.sol" not found: File outside of allowed directories..
The compiler will refuse to import files from outside of your project directory unless you specifically tell it it's fine. You can do this using
--allow-paths option. This should contain the directory where you installed chainlink.
Note that, if you're using solc from Docker, it should be a directory in container's filesystem rather than in your local filesystem. The fact that there are two parallel filesystems connected via Docker volumes is often confusing to users which is why, again, I'd recommend a static binary instead - it will make dealing with paths much more straightforward.