Skip to content

fnichol/docker-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Programming Language Docker Images

Build Status

Supported tags

What is Rust?

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.

wikipedia.org/wiki/Rust_(programming_language)

logo

How to use this image

Compile your app or library inside a Docker container

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

Run your app inside a Docker container

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

Caching CARGO_HOME

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

Image variants

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.

License

View license information for the software contained in this image.

Supported Docker versions

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.

User feedback

Documentation

Documentation for this image is contained in this README.md.

Issues

If you have any problems with or questions about this image, please contact us through a GitHub issue.

Contributing

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.

About

Rust Programming Language Docker Images!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages