Public | Automated Build

Last pushed: a year ago
Short Description
This repository creates images that can be used to create a running Rust instance in a container.
Full Description


Source code for the Dockerfile and and build scripts needed to use the container listed on Docker hub.

Supported Tags and Respective Dockerfile links

What is Rust?

Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It maintains these goals without having a garbage collector, making it a useful language for a number of use cases other languages aren’t good at: embedding in other languages, programs with specific space and time requirements, and writing low-level code, like device drivers and operating systems. It improves on current languages targeting this space by having a number of compile-time safety checks that produce no runtime overhead, while eliminating all data races. Rust also aims to achieve ‘zero-cost abstractions’ even though some of these abstractions feel like those of a high-level language. Even then, Rust still allows precise control like a low-level language would.

How to use this image?

For getting started, consider using the onbuild variant. It can be used by running the command below in the root directory of your cargo project.

docker run -it --rm --name first-rust peternator7/docker-rust:1.8.0-onbuild

It will copy your Cargo.toml and your Cargo.lock as well as everything in your src directory into the container and then call cargo run inside of the container. Cargo handles downloading all of your dependencies and then deploying your application.

If you plan on building an image once then running the binary multiple times, consider adding this change to your Dockerfile. This will build all the dependencies one time when the image is built instead of every time the container is started like the default unbuild does.

# Place this in the root directory of your cargo project
FROM peternator7/docker-rust:1.8.0-onbuild
RUN cargo build

Docker will still execute cargo run but Cargo is smart enough to not recompile code that hasn't been changed so it will not compile anything before executing.

Known Issues

There is currently no way of specifying a debug or a release build via the existing image. This can be easily fixed by adding a target as a parameter in CMD though.

Docker Pull Command
Source Repository

Comments (0)