Sitemap

Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Create an Optimized Rust Alpine Docker Image

4 min readJun 6, 2022

--

Running your Rust application on an Alpine Docker image isn't straightforward. But don't worry. I will show you how you can create an optimized and small Rust Docker image based on Alpine Linux.

Press enter or click to view image in full size
Rust Programming Language

GitHub Repository

If you are interested in the whole application and want to check out the used code, look at this GitHub repository I created for this article.

For this demo, I set up a simple web server using thewarp and tokio crates and only expose a GET /hello/:text endpoint that returns a string Hello, :text!.

Using this small web server, we can verify that the Docker image is built and runs correctly at the end of the article.

Why you can't simply use Alpine as runtime

If you built your Docker image the "normal" way, you would run into errors when running your Rust application on Alpine, even if your Docker build succeeded.

It breaks because specific libraries are missing on Alpine, which many Rust applications need to…

--

--

Level Up Coding
Level Up Coding
Pascal Zwikirsch
Pascal Zwikirsch

Written by Pascal Zwikirsch

Solution Architect | Technical Writer | Passionate Developer

Responses (1)