2.11.2. Adding an image volume to a pod


To mount an Open Container Initiative (OCI)-compliant container image, use the volume parameter to include a path to the image in your pod spec with an optional pull policy. You can create the pod directly or use a controlling object, such as a deployment or replica set.

Procedure

  1. Create a YAML file similar to the following.

    apiVersion: v1
    kind: Pod
    metadata:
      name: image-volume
    spec:
      containers:
      - name: shell
        command: ["sleep", "infinity"]
        image: debian
        volumeMounts:
        - name: volume
          mountPath: /volume
      volumes:
      - name: volume
        image: 
    1
    
          reference: quay.io/crio/image:v2 
    2
    
          pullPolicy: Always 
    3
    1
    Specifies an OCI container image that is available on the host machine.
    2
    Specifies the path to the image.
    3
    Specifies a pull policy, one of the following options:
    • If Always, the kubelet always attempts to pull the image. If the pull fails, the kubelet sets the pod to Failed.
    • If Never, the kubelet never pulls the image and only uses a local image. The pod becomes Failed if any layers of the image are not present locally, or if the manifest for that image is not already cached.
    • If IfNotPresent the kubelet pulls the image if it is not present. The pod becomes Failed if the image is not present and the pull fails. This is the default.
  2. Create the pod by running the following command:

    $ oc create -f <file_name>.yaml

Verification

  • Examine the pod to view detailed information about the image pull and mount by using a command similar to the following:

    $ oc describe pod <pod_name>

    Example output

    Name:             image-volume
    Namespace:        default
    # ...
    Volumes:
      volume: 
    1
    
        Type:        Image
        Reference:   quay.io/crio/image:v2
        PullPolicy:  IfNotPresent
    # ...
    Events:
      Type    Reason          Age                From               Message
      ----    ------          ----               ----               -------
    # ...
      Normal  Pulling         46s                kubelet            Pulling image "quay.io/crio/image:v2"
      Normal  Pulled          44s                kubelet            Successfully pulled image "quay.io/crio/image:v2" in 2.261s (2.261s including waiting). Image size: 6707 bytes. 
    2
    
    # ...

    1
    Indicates that the image was mounted to the pod.
    2
    Indicates that the image was successfully pulled.
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

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

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

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

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동