Published in


Rust + Docker: Easy packaging of your applications

Rust is a popular programming language known for its performance, safety, and concurrency. One way to package and distribute Rust applications is through Docker, a platform for building, running, and distributing containerised applications.

To create a Docker container for a Rust application, you must have Docker installed on your machine. Then, create a new Rust project using the cargo package manager:

Next, create a file called Dockerfile in the project’s root directory. This file will contain the instructions for building the Docker image for your application.

To create a minimal Docker image for a Rust application, you can use the following Dockerfile:

FROM rust:latest

# Set the working directory
WORKDIR /usr/src/app

# Copy the code
COPY . .

# Build the code
RUN cargo build --release

# Set the binary as the entrypoint
ENTRYPOINT ["/usr/src/app/target/release/hello-world"]

This Dockerfile uses the official Rust image as the base image, copies the code from the current directory into the container, builds the release version of the code, and sets the binary as the entrypoint for the container.

Source: ITNEXT

To build the Docker image, run the following command in the root directory of the project:

This will create a Docker image with the name hello-world. To run the container, use the following command:

This will start the container and bind it to port 8080 on the host machine. You can access the application by visiting http://localhost:8080 in a web browser.

To modify the application to listen on a different address and port, you can use the and types from the Rust standard library.

For example, to listen on the loopback interface ( on port 8080, you can use the following code:

use std::net::TcpListener;

fn main() {
let listener = TcpListener::bind("").unwrap();
println!("Listening on {}", listener.local_addr().unwrap());

To listen on all available interfaces, you can use the address:

use std::net::TcpListener;

fn main() {
let listener = TcpListener::bind("").unwrap();
println!("Listening on {}", listener.local_addr().unwrap());

Using Rust and Docker together you can easily package and distribute your applications, making it easy to run them on any machine with Docker installed.

Comment below on other topics you’d like me to cover using Rust!


Rust is an excellent choice for building applications that must be performant and safe. Its strong emphasis on memory safety and concurrent programming makes it well-suited for various tasks. At Vaultree, we used Rust as the primary language for our data-in-use SDK. If you’re interested in learning more about how the world’s first fully functional data-in-use encryption solution works, you can contact us and learn more about what we do. Count on us to help secure your databases and sensitive information while building more robust and reliable applications.

About Vaultree

Vaultree has developed the world’s first Fully Functional Data-in-Use Encryption solution that solves the industry’s fundamental security issue: persistent data encryption, even in the event of a leak. Vaultree enables enterprises, including those in the financial services and healthcare / pharmaceutical sectors, to mitigate the great financial, cyber, legal, and business risk of a data breach in plain text. With Vaultree, organisations process, search, and compute ubiquitous data at scale, without ever having to surrender encryption keys or decrypt server-side. If a leak occurs, Vaultree’s data-in-use encryption persists, rendering the data unusable to bad actors. Integrating Vaultree into existing database technologies is seamless, requiring no technology or platform changes. Vaultree is a privately held company based in Ireland and the U.S.

For more information, please visit



Vaultree’s Encryption-in-use enables businesses of all sizes to process (search and compute) fully end-to-end encrypted data without the need to decrypt.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vaultree Tech Community

Vaultree is a revolutionary encryption startup allowing processing of fully encrypted data at run-time. Let’s create an encrypted tomorrow…together!