### Navigate to Example Directory Source: https://github.com/googlecontainertools/distroless/blob/main/README.md Change the current directory to the Python 3 examples directory. ```sh cd examples/python3/ ``` -------------------------------- ### Example Output Source: https://github.com/googlecontainertools/distroless/blob/main/examples/python3-requirements/README.md Shows the expected output when the Python 3 application is run. ```text RSS: 13.0 MiB; SHARED: 5.7 MiB; VIRTUAL: 19.9 MiB ``` -------------------------------- ### Build and Run Distroless Example Source: https://github.com/googlecontainertools/distroless/blob/main/README.md Standard commands to build a Docker image from a Dockerfile and run it. Assumes the Dockerfile is in the current directory. ```sh docker build -t myapp . docker run -t myapp ``` -------------------------------- ### Live Execution Example for Update Mode Source: https://github.com/googlecontainertools/distroless/blob/main/private/tools/lifecycle/tag.sh.README.md This example shows how to perform a live execution of the 'update' mode. Setting the DRY_RUN environment variable to 'false' enables the script to apply tags directly to the container registry. ```bash DRY_RUN=false ./tag.sh update gcr.io/distroless/python3-debian13 ``` -------------------------------- ### Dry Run Example for Update Mode Source: https://github.com/googlecontainertools/distroless/blob/main/private/tools/lifecycle/tag.sh.README.md This example demonstrates a dry run of the 'update' mode. By default, the script only prints the actions it would take without applying any tags to the registry. ```bash ./tag.sh update gcr.io/distroless/python3-debian13 ``` -------------------------------- ### Build a Single Distroless Image with Bazel Source: https://github.com/googlecontainertools/distroless/blob/main/CONTRIBUTING.md Use this command to build a specific Distroless image. Ensure Bazel is installed and configured. ```bash bazel build //base:static_root_amd64_debian17 ``` -------------------------------- ### Go Application Docker Multi-stage Build Source: https://github.com/googlecontainertools/distroless/blob/main/README.md Example of a Docker multi-stage build for a Go application using a distroless base image. This first stage builds the Go binary, and the second stage copies it into the distroless image. ```dockerfile # Start by building the application. FROM golang:1.18 as build WORKDIR /go/src/app COPY . . RUN go mod download RUN CGO_ENABLED=0 go build -o /go/bin/app # Now copy it into our base image. FROM gcr.io/distroless/static-debian13 COPY --from=build /go/bin/app / CMD ["/app"] ``` -------------------------------- ### Format Bazel Files with Buildifier Source: https://github.com/googlecontainertools/distroless/blob/main/CONTRIBUTING.md Install and use buildifier to automatically fix the style of Bazel BUILD and WORKSPACE files. This command targets files with names starting with 'BUILD' or 'WORKSPACE', or ending with '.bzl'. ```bash # Install buildifier version 3.2.0 go install github.com/bazelbuild/buildtools/buildifier@latest # This will automatically fix files. buildifier -mode=fix $(find . -name 'BUILD*' -o -name 'WORKSPACE*' -o -name '*.bzl' -type f) ``` -------------------------------- ### Dockerfile ENTRYPOINT Invalid Form Source: https://github.com/googlecontainertools/distroless/blob/main/README.md This is an example of an invalid Dockerfile ENTRYPOINT format when using distroless images. It should be specified in vector form. ```dockerfile ENTRYPOINT "myapp" ``` -------------------------------- ### Verify Distroless Image Signature Source: https://github.com/googlecontainertools/distroless/blob/main/README.md Use this command to verify the keyless signature of any distroless image using cosign. Ensure you have cosign installed and the IMAGE_NAME environment variable set. ```sh cosign verify $IMAGE_NAME --certificate-oidc-issuer https://accounts.google.com --certificate-identity keyless@distroless.iam.gserviceaccount.com ``` -------------------------------- ### Identify Python Style Issues with Pylint Source: https://github.com/googlecontainertools/distroless/blob/main/CONTRIBUTING.md Install pylint using pip, apt, or brew, then use this command to find Python style issues. The `--disable=R,C` flags are used to ignore specific categories of warnings. ```bash # Install pylint sudo pip install pylint # Or sudo apt-get install pylint # Or on macos brew install pylint # Identify python style issues. find . -name "*.py" | xargs pylint --disable=R,C ``` -------------------------------- ### Run Node.js Express App with Port Exposure Source: https://github.com/googlecontainertools/distroless/blob/main/README.md Commands to install Node.js dependencies, build a Docker image for a Node.js Express app, and run it, exposing port 3000. This allows access to the app via localhost:3000. ```sh npm install # Install express and its transitive dependencies docker build -t myexpressapp . docker run -p 3000:3000 -t myexpressapp ``` -------------------------------- ### Build and Run Python 3 App Source: https://github.com/googlecontainertools/distroless/blob/main/examples/python3-requirements/README.md Build the Docker image for the Python 3 application and then run it. ```bash docker build . --tag=psutil-example ``` ```bash docker run --rm psutil-example ``` -------------------------------- ### Generate dpkg MD5sums File Source: https://github.com/googlecontainertools/distroless/blob/main/PACKAGE_METADATA.md Demonstrates the process of generating the `.md5sums` file for a package using `dpkg-deb --control` and copying the `md5sums` file. ```bash dpkg-deb --control .deb CONTROL cp CONTROL/md5sums /var/lib/dpkg/status.d/.md5sums rm -rf CONTROL ``` -------------------------------- ### Run Debug Image with Shell Entrypoint Source: https://github.com/googlecontainertools/distroless/blob/main/README.md Launch the built debug image interactively with a shell entrypoint to explore the container filesystem. ```sh docker run --entrypoint=sh -ti my_debug_image ``` -------------------------------- ### Distroless dpkg Metadata Directory Structure Source: https://github.com/googlecontainertools/distroless/blob/main/PACKAGE_METADATA.md Illustrates the relevant directory structure for dpkg metadata in Distroless Debian images, utilizing the `status.d` directory. ```bash /var/lib/dpkg/ └── status.d/ ├── └── .md5sums ``` -------------------------------- ### Generate dpkg Package Metadata Source: https://github.com/googlecontainertools/distroless/blob/main/PACKAGE_METADATA.md Shows how to generate package metadata files equivalent to those found in `/var/lib/dpkg/status.d/` using `dpkg-deb --field`. ```bash dpkg-deb --field .deb > /var/lib/dpkg/status.d/ ``` -------------------------------- ### Load a Built Distroless Image into Docker Daemon Source: https://github.com/googlecontainertools/distroless/blob/main/CONTRIBUTING.md This Starlark rule and subsequent Bazel command are used to load a built Distroless image into your local Docker engine. Define the `oci_load` rule in your BUILD file. ```starlark load("@rules_oci//oci:defs.bzl", "oci_load") oci_load( name = "local_build", image = "//base:static_root_amd64_debian17", repo_tags = [], ) ``` ```shell bazel run //:local_build ``` -------------------------------- ### Dockerfile ENTRYPOINT Vector Form Source: https://github.com/googlecontainertools/distroless/blob/main/README.md When using distroless images, the Dockerfile ENTRYPOINT must be specified in vector form to avoid a shell prefixing the command. This ensures the command runs directly. ```dockerfile ENTRYPOINT ["myapp"] ``` -------------------------------- ### Basic Usage of Lifecycle Tagger Source: https://github.com/googlecontainertools/distroless/blob/main/private/tools/lifecycle/tag.sh.README.md This command shows the basic syntax for using the tagger script. It specifies the mode ('update' or 'deprecate') and the target image. ```bash ./tag.sh [update|deprecate] ``` -------------------------------- ### Build Debug Image Source: https://github.com/googlecontainertools/distroless/blob/main/README.md Build the Docker image using the modified Dockerfile. ```sh docker build -t my_debug_image . ``` -------------------------------- ### List Files in Debug Container Source: https://github.com/googlecontainertools/distroless/blob/main/README.md After entering the debug container, list the files in the current directory. ```sh /app # ls BUILD Dockerfile hello.py ``` -------------------------------- ### Regenerate Lock Files with Knife Lock Source: https://github.com/googlecontainertools/distroless/blob/main/CONTRIBUTING.md Run this command after making changes to common YAML manifest files to regenerate lock files. Ensure the 'knife' tool is available in your PATH. ```bash ./knife lock ``` -------------------------------- ### Modify Dockerfile for Debug Image Source: https://github.com/googlecontainertools/distroless/blob/main/README.md Update the Dockerfile to use the ':debug' tag for a Distroless image, enabling shell access. ```dockerfile FROM gcr.io/distroless/python3-debian13:debug COPY . /app WORKDIR /app CMD ["hello.py", "/etc"] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.