Skip to main content

Run Cargo via Docker for local development

My setup to run cargo via Docker as the current user. Put that in your Makefile or as shell alias.

docker run --rm -ti \                            # run, remove afterwards, use terminal
        -w /src -v `pwd`:/src \                  # map cwd to /src and make it the WORKDIR
        --user `id -u`:`id -g` -e USER=`id -u` \ # map to current user
        -e CARGO_HOME=/src/.cargo_registry \     # change the CARGO_HOME into the src
        rust:1.38 \                              # image:version
        cargo

(Note: don't add the comments, the shell won't kike it)