You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "mfatemipour (via GitHub)" <gi...@apache.org> on 2026/05/04 09:02:41 UTC

Re: [PR] Add support for templating the DockerOperator `mounts` parameter [airflow]

mfatemipour commented on PR #52451:
URL: https://github.com/apache/airflow/pull/52451#issuecomment-4369589257

   Hi, I am getting following exception that I think is related to this change
   
   ```python
   Traceback (most recent call last):
     File "/home/airflow/.local/lib/python3.14/site-packages/airflow/sdk/bases/operator.py", line 548, in apply_defaults
       result = func(self, **kwargs, default_args=default_args)
     File "/home/airflow/.local/lib/python3.14/site-packages/airflow/providers/docker/operators/docker.py", line 309, in __init__
       mount.template_fields = ("Source", "Target", "Type")
       ^^^^^^^^^^^^^^^^^^^^^
   AttributeError: 'dict' object has no attribute 'template_fields' and no __dict__ for setting new attributes
   ```
   I was using a dict object for mounts like this
   
   ```python
       write_to_dst_task = MyOperator(
           ...
           mounts=[
               {
                   "type": "volume",
                   "source": "{{ params.dst_volume }}",
                   "target": "/data/",
                   "read_only": False,
               }
           ],
           ...
       )
   ```
   
   And I added `mounts` to template_fields of MyOperator, not after upgrading to latest version it failed, event using docker.types.Mount instead of dict didn't solve it
   
   ```python
       write_to_dst_task = MyOperator(
           ...
           mounts=[
               types.Mount(
                   target="/data/",
                   source="{{ params.dst_volume }}",
                   type="volume",
                   read_only=False,
               ),
           ],
           ...
       )
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org