title: How to mount a volume to a Kubernetes Pod running a docker container from the Airflow host that triggers it using the KubernetesPodOperator
body: <p>I have a DAG in airflow that uses the <a href="https://airflow.readthedocs.io/en/stable/_api/airflow/contrib/operators/kubernetes_pod_operator/" rel="nofollow noreferrer">KubernetesPodOperator</a> and I am trying to get some files that are generated by the container running in the pod back to the airflow host. For development my host is a Docker container running an <a href="https://github.com/puckel/docker-airflow" rel="nofollow noreferrer">airflow image</a> with a docker-desktop K8s cluster and for production I am using an AWS EC2 box with EKS.</p>
  <pre><code>volume_mount = VolumeMount('dbt-home',
                             mount_path=&lt;CONTAINER_DIR&gt;,
                             sub_path=None,
                             read_only=False)
  
  volume_config= {
      'hostPath':
        {'path': &lt;HOST_DIR&gt;, 'type': 'DirectoryOrCreate'}
      }
  
  volume = Volume(name=&quot;dbt-home&quot;, configs=volume_config)
  
  
  dbt_run = KubernetesPodOperator(
                            namespace='default',
                            image=MY_IMAGE&gt;,
                            cmds=[&quot;bash&quot;, &quot;-cx&quot;],
                            arguments=[command],
                            env_vars=MY_ENVIRONMENT,
                            volumes=[volume],
                            volume_mounts=[volume_mount],
                            name=&quot;test-run&quot;,
                            task_id=&quot;test-run-task&quot;,
                            config_file=config_file,
                            get_logs=True,
                            reattach_on_restart=True,
                            dag=dag
                            )
  </code></pre>
  <p>I tried using the hostPath type for the volume but i think that it refers to the host of the pod. I looked in the kubernetes documentation around volumes where I found the EmptyDir one which didnt work out either.</p>