From 4c614d0c216f5eda0df73a93ecc40bade0c0bd31 Mon Sep 17 00:00:00 2001 From: Peter Suschlik Date: Wed, 9 Nov 2016 23:44:27 +0100 Subject: [PATCH] Rust: Mention running cargo as local user Hi, thanks for making this wonderful docker container! It makes exploring rust even more fun :greenheart: Running programs as root might be risky and should be avoided :-) This PR describes the in README. Thanks again and kind regards, Peter --- rust/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rust/README.md b/rust/README.md index f16d62c..47bdbe2 100644 --- a/rust/README.md +++ b/rust/README.md @@ -26,3 +26,19 @@ The `$USER` environment variable can be specified, which is used by `cargo`. The $ docker run --rm -it -e USER="John Doe" -v $(pwd):/source schickling/rust ``` +#### Running cargo as local user + +In order to run cargo as a local user and not as root run this: + +```sh +$ docker run --rm -it \ + -u $UID \ + -e USER=$USER \ + -e CARGO_HOME=/source/.cargo \ + -v $HOME/.cargo:/source/.cargo \ + -v $(pwd):/source \ + schickling/rust \ + cargo build +``` + +Note the new volume for the cargo cache and the `-u` flag.