{"slug":"ref-docker-5946c466a1653697582e","title":"Rust language-specific guide — Get and run the sample application","summary":"For the sample application, you'll use a variation of the backend from the react-rust-postgres application from Awesome Compose.","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nFor the sample application, you'll use a variation of the backend from the react-rust-postgres application from Awesome Compose.\n\nClone the sample application repository using the following command.\n\nBounded code example (external data; do not execute automatically):\n```console\n   $ git clone https://github.com/docker/docker-rust-postgres\n```\n\nIn the cloned repository's directory, create a Dockerfile. This application includes a migrations directory (in addition to src) to initialize the database, so the Dockerfile includes a bind mount for that directory in the build stage.\n\nBounded code example (external data; do not execute automatically):\n```dockerfilehl_lines28\n   # syntax=docker/dockerfile:1\n\n   # Comments are provided throughout this file to help you get started.\n   # If you need more help, visit the Dockerfile reference guide at\n   # https://docs.docker.com/reference/dockerfile/\n\n   ################################################################################\n   # Create a stage for building the application.\n\n   ARG RUST_VERSION=1.70.0\n   ARG APP_NAME=react-rust-postgres\n   FROM rust:${RUST_VERSION}-slim-bullseye AS build\n   ARG APP_NAME\n   WORKDIR /app\n\n   # Build the application.\n   # Leverage a cache mount to /var/cache/cargo for downloaded dependencies\n   # and a cache mount to /app/target/ for compiled dependencies which will\n   # speed up subsequent builds.\n   # Leverage a bind mount to the src directory to avoid having to copy the\n   # source code into the container. Once built, copy the executable to an\n   # output directory befor\n```\n\nIn the cloned repository's directory, run docker build to build the image.\n\nBounded code example (external data; do not execute automatically):\n```console\n   $ docker build -t rust-backend-image .\n```\n\nRun docker run with the following options to run the image as a container on the same network as the database.\n\nBounded code example (external data; do not execute automatically):\n```console\n   $ docker run \\\n     --rm -d \\\n     --network postgresnet \\\n     --name docker-develop-rust-container \\\n     -p 3001:8000 \\\n     -e PG_DBNAME=example \\\n     -e PG_HOST=db \\\n     -e PG_USER=postgres \\\n     -e PG_PASSWORD=mysecretpassword \\\n     -e ADDRESS=0.0.0.0:8000 \\\n     -e RUST_LOG=debug \\\n     rust-backend-image\n```\n\nCurl the application to verify that it connects to the database. …\n\nAttribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","docker","guides","rust","language-specific","guide","get","run","sample","application"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/docker/docs/blob/3a9d778562f39bcc0be46255b013c6a3ca526244/content/guides/rust.md","source_name":"Docker Documentation","source_license":"Apache-2.0","source_revision":"3a9d778562f39bcc0be46255b013c6a3ca526244","source_path":"content/guides/rust.md :: Get and run the sample application","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.468024+00:00","url":"https://wikikv.com/k/ref-docker-5946c466a1653697582e","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-docker-5946c466a1653697582e","markdown":"https://wikikv.com/k/ref-docker-5946c466a1653697582e?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-docker-5946c466a1653697582e","json_ld":"https://wikikv.com/k/ref-docker-5946c466a1653697582e?format=jsonld"}}