fnichol/rust
Rust (rustlang) is a general-purpose, compiled programming language developed by Mozilla Research.
5.0K
nightly
(nightly/Dockerfile)nightly-slim
(nightly/slim/Dockerfile)1.15.1
(1.15.1/Dockerfile)1.15.1-musl
(1.15.1/musl/Dockerfile)1.15.1-slim
(1.15.1/slim/Dockerfile)1.15.0
(1.15.0/Dockerfile)1.15.0-musl
(1.15.0/musl/Dockerfile)1.15.0-slim
(1.15.0/slim/Dockerfile)1.14.0
(1.14.0/Dockerfile)1.14.0-musl
(1.14.0/musl/Dockerfile)1.14.0-slim
(1.14.0/slim/Dockerfile)1.13.0
(1.13.0/Dockerfile)1.13.0-musl
(1.13.0/musl/Dockerfile)1.13.0-slim
(1.13.0/slim/Dockerfile)1.12.0
(1.12.0/Dockerfile)1.12.0-musl
(1.12.0/musl/Dockerfile)1.12.0-slim
(1.12.0/slim/Dockerfile)1.11.0
(1.11.0/Dockerfile)1.11.0-musl
(1.11.0/musl/Dockerfile)1.11.0-slim
(1.11.0/slim/Dockerfile)1.10.0
(1.10.0/Dockerfile)1.10.0-musl
(1.10.0/musl/Dockerfile)1.10.0-slim
(1.10.0/slim/Dockerfile)1.9.0
(1.9.0/Dockerfile)1.9.0-musl
(1.9.0/musl/Dockerfile)1.9.0-slim
(1.9.0/slim/Dockerfile)1.8.0
(1.8.0/Dockerfile)1.8.0-musl
(1.8.0/musl/Dockerfile)1.8.0-slim
(1.8.0/slim/Dockerfile)1.7.0
(1.7.0/Dockerfile)1.7.0-musl
(1.7.0/musl/Dockerfile)1.7.0-slim
(1.7.0/slim/Dockerfile)1.6.0
(1.6.0/Dockerfile)1.6.0-musl
(1.6.0/musl/Dockerfile)1.6.0-slim
(1.6.0/slim/Dockerfile)1.5.0
(1.5.0/Dockerfile)1.5.0-musl
(1.5.0/musl/Dockerfile)1.5.0-slim
(1.5.0/slim/Dockerfile)1.4.0
(1.4.0/Dockerfile)1.4.0-musl
(1.4.0/musl/Dockerfile)1.4.0-slim
(1.4.0/slim/Dockerfile)1.3.0
(1.3.0/Dockerfile)1.3.0-slim
(1.3.0/slim/Dockerfile)1.2.0
(1.2.0/Dockerfile)1.2.0-slim
(1.2.0/slim/Dockerfile)Rust is a general-purpose, multi-paradigm, compiled programming language developed by Mozilla Research. It is designed to be a "safe, concurrent, practical language", supporting pure-functional, concurrent-actor, imperative-procedural, and object-oriented styles.
There may be occasions where it is not appropriate to run your app inside a container. To compile, but not run your app inside the instance, you can write something like this:
docker run --rm -v $(pwd):/src fnichol/rust:1.15.1 cargo build --release
This will add your current directory as a volume to the container and run the command cargo build --release
which will perform a release build (i.e. no debug symbols) of your project and output the executable under ./target/release/
. Alternatively, if you have a Makefile
, you can run the make
command inside your container.
docker run --rm -v $(pwd):/src fnichol/rust:1.15.1 make
While you are strongly encouraged to repackage a smaller Docker image with your compiled app for production use, it may be useful to run your app in development. For this, you can invoke cargo run
:
docker run --rm -v $(pwd):/src fnichol/rust:1.15.1 cargo run
All the images set the CARGO_HOME
environment variable to /cargo
which means that you can use the data volume pattern to cache the contents of /cargo
between runs of containers. First, you need to set up a data volume container to host the Cargo home:
docker create -v /cargo --name cargo-cache tianon/true /bin/true
Finally, use the --volumes-from
flag when starting containers to mount /cargo
in:
docker run --rm -v $(pwd):/src --volumes-from cargo-cache fnichol/rust:1.12.0 cargo build
The fnichol/rust
images come in many flavors, each designed for a specific use case.
fnichol/rust:<version>
This is the defacto image. If you are unsure about what your needs are, you probably want to use this one.
fnichol/rust:<version>-slim
This image does not contain the common packages contained in the default tag and only contains the minimal packages needed to run rustc
and cargo
for most projects. Unless you are working in an evironment where only the rust image will be deployed and you have space constraints, we highly recommend using the default image of this repository.
fnichol/rust:<version>-musl
This image has a source-build version of Rust (and Cargo) which is has has musl support with the compiler. This enables a --target x86_64-unknown-linux-musl
target for rustc
and cargo build
which can lead to completely static binaries with no reliance on a libc at runtime. For more information, check out the Rust book and this Rust pull request with more details.
View license information for the software contained in this image.
This image is officially supported on Docker version 1.11.2.
Support for older versions (down to 1.6) is provided on a best-effort basis.
Please see the Docker installation documentation for details on how to upgrade your Docker daemon.
Documentation for this image is contained in this README.md.
If you have any problems with or questions about this image, please contact us through a GitHub issue.
You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
docker pull fnichol/rust