이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 2. Creating a custom container image


You can create a container image from your Quarkus application using one of the following methods:

  • Creating a container manually
  • Creating a container using the OpenShift Docker build
Important

Compiling a Quarkus application to a native executable consumes a lot of memory during analysis and optimization. You can limit the amount of memory used during native compilation by setting the quarkus.native.native-image-xmx configuration property. Setting low memory limits might increase the build time.

2.1. Creating a container manually

This section shows you how to manually create a container image with your application for Linux X86_64. When you produce a native image using the Quarkus Native container it creates an executable that targets the Linux X86_64 operating system. If your host operating system is different from this, you will not be able to run the binary directly and you will need to create a container manually.

Your Quarkus Getting Started project includes a Dockerfile.native in the src/main/docker directory with the following content:

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
WORKDIR /work/
RUN chown 1001 /work \
    && chmod "g+rwX" /work \
    && chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application

EXPOSE 8080
USER 1001

CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
Copy to Clipboard Toggle word wrap
Universal Base Image (UBI)

The Dockerfiles use UBI as a base image. This base image was designed to work in containers. The Dockerfiles use the minimal version of the base image to reduce the size of the produced image.

Procedure

  1. Build a native Linux executable using one of the following methods:

    1. Build a native executable with Docker:

      ./mvnw package -Pnative -Dquarkus.native.container-build=true
      Copy to Clipboard Toggle word wrap
    2. Build a native executable with Podman:

      ./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.container-runtime=podman
      Copy to Clipboard Toggle word wrap
  2. Build the container image using one of the following methods:

    1. Build the container image with Docker:

      docker build -f src/main/docker/Dockerfile.native -t quarkus-quickstart/getting-started .
      Copy to Clipboard Toggle word wrap
    2. Build the container image with Podman

      podman build -f src/main/docker/Dockerfile.native -t quarkus-quickstart/getting-started .
      Copy to Clipboard Toggle word wrap
  3. Run the container:

    1. Run the container with Docker:

      docker run -i --rm -p 8080:8080 quarkus-quickstart/getting-started
      Copy to Clipboard Toggle word wrap
    2. Run the container with Podman:

      podman run -i --rm -p 8080:8080 quarkus-quickstart/getting-started
      Copy to Clipboard Toggle word wrap

2.2. Creating a container using the OpenShift Docker build

You can create a container image for your Quarkus application using the OpenShift Docker build strategy. This strategy creates a container using a build configuration in the cluster.

Prerequisites

  • You have access to a Red Hat OpenShift Container Platform cluster and the latest version of the OpenShift CLI (oc) is installed. For information about installing oc, see the "Installing the CLI" section of the Installing and configuring OpenShift Container Platform clusters guide.
  • A URL for the OpenShift API endpoint.

Procedure

  1. Log in to the OpenShift CLI:

    oc login -u <username_url>
    Copy to Clipboard Toggle word wrap
  2. Create a new project in OpenShift:

    oc new-project <project_name>
    Copy to Clipboard Toggle word wrap
  3. Create a build config based on the src/main/docker/Dockerfile.native file:

    cat src/main/docker/Dockerfile.native | oc new-build --name <build_name> --strategy=docker --dockerfile -
    Copy to Clipboard Toggle word wrap
  4. Build the project:

    oc start-build <build_name> --from-dir .
    Copy to Clipboard Toggle word wrap
  5. Deploy the project to OpenShift:

    oc new-app <build_name>
    Copy to Clipboard Toggle word wrap
  6. Expose the services:

    oc expose svc/<build_name>
    Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat