title: mounting directories using docker operator on airflow is not working
body: <p>I'm trying to use the docker operator to automate the execution of some scripts using airflow.</p>
  <p>Airflow version: <code>apache-airflow==1.10.12</code></p>
  <p>What I want to do is to &quot;copy&quot; all my project's files (with folders and files) to the container using this code.</p>
  <p>The following file <code>ml-intermediate.py</code> is in this directory <code>~/airflow/dags/ml-intermediate.py</code>:</p>
  <pre><code>&quot;&quot;&quot;
  Template to convert a Ploomber DAG to Airflow
  &quot;&quot;&quot;
  from airflow import DAG
  from airflow.operators.bash_operator import BashOperator
  from airflow.utils.dates import days_ago
  
  from ploomber.spec import DAGSpec
  from soopervisor.script.ScriptConfig import ScriptConfig
  
  script_cfg = ScriptConfig.from_path('/home/letyndr/airflow/dags/ml-intermediate')
  # Replace the project root to reflect the new location - or maybe just
  # write a soopervisor.yaml, then we can we rid of this line
  script_cfg.paths.project = '/home/letyndr/airflow/dags/ml-intermediate'
  
  # TODO: use lazy_import from script_cfg
  dag_ploomber = DAGSpec('/home/letyndr/airflow/dags/ml-intermediate/pipeline.yaml',
                         lazy_import=True).to_dag()
  dag_ploomber.name = &quot;ML Intermediate&quot;
  
  default_args = {
      'start_date': days_ago(0),
  }
  
  dag_airflow = DAG(
      dag_ploomber.name.replace(' ', '-'),
      default_args=default_args,
      description='Ploomber dag',
      schedule_interval=None,
  )
  
  script_cfg.save_script()
  
  from airflow.operators.docker_operator import DockerOperator
  for task_name in dag_ploomber:
      DockerOperator(task_id=task_name,
          image=&quot;continuumio/miniconda3&quot;,
          api_version=&quot;auto&quot;,
          auto_remove=True,
          # command=&quot;sh /home/letyndr/airflow/dags/ml-intermediate/script.sh&quot;,
          command=&quot;sleep 600&quot;,
          docker_url=&quot;unix://var/run/docker.sock&quot;,
          volumes=[
              &quot;/home/letyndr/airflow/dags/ml-intermediate:/home/letyndr/airflow/dags/ml-intermediate:rw&quot;,
              &quot;/home/letyndr/airflow-data/ml-intermediate:/home/letyndr/airflow-data/ml-intermediate:rw&quot;
          ],
          working_dir=script_cfg.paths.project,
          dag=dag_airflow,
          container_name=task_name,
      )
  
  
  
  for task_name in dag_ploomber:
      task_ploomber = dag_ploomber[task_name]
      task_airflow = dag_airflow.get_task(task_name)
  
      for upstream in task_ploomber.upstream:
          task_airflow.set_upstream(dag_airflow.get_task(upstream))
  
  dag = dag_airflow
  </code></pre>
  <p>When I execute this DAG using Airflow, I get the error that the docker does not find the <code>/home/letyndr/airflow/dags/ml-intermediate/script.sh</code> script. I changed the execution command of the docker operator <code>sleep 600</code> to enter to the container and check the files in the container with the corrects paths.</p>
  <p>When I'm in the container I can go to this path <code>/home/letyndr/airflow/dags/ml-intermediate/</code> for example, but I don't see the files that are supposed to be there.</p>
  <p>I tried to replicate how Airflow implements <a href="https://docker-py.readthedocs.io/en/stable/" rel="nofollow noreferrer">Docker SDK for Python</a> checking this part of the package <a href="https://github.com/apache/airflow/blob/master/airflow/providers/docker/operators/docker.py" rel="nofollow noreferrer">docker operator Airflow</a>, specifically, this one where it creates the docker container: <a href="https://github.com/apache/airflow/blob/master/airflow/providers/docker/operators/docker.py#L231" rel="nofollow noreferrer">docker container creation</a></p>
  <p>This is my one replication of the docker implementation:</p>
  <pre><code>import docker
  
  client = docker.APIClient()
  
  # binds = {
  #         &quot;/home/letyndr/airflow/dags&quot;: {
  #             &quot;bind&quot;: &quot;/home/letyndr/airflow/dags&quot;,
  #             &quot;mode&quot;: &quot;rw&quot;
  #         },
  #         &quot;/home/letyndr/airflow-data/ml-intermediate&quot;: {
  #             &quot;bind&quot;: &quot;/home/letyndr/airflow-data/ml-intermediate&quot;,
  #             &quot;mode&quot;: &quot;rw&quot;
  #         }
  #     }
  
  binds = [&quot;/home/letyndr/airflow/dags:/home/letyndr/airflow/dags:rw&quot;,
  &quot;/home/letyndr/airflow-data/ml-intermediate:/home/letyndr/airflow-data/ml-intermediate:rw&quot;]
  
  container = client.create_container(
      image=&quot;continuumio/miniconda3&quot;,
      command=&quot;sleep 600&quot;,
      volumes=[&quot;/home/letyndr/airflow/dags&quot;, &quot;/home/letyndr/airflow-data/ml-intermediate&quot;],
      host_config=client.create_host_config(binds=binds),
      working_dir=&quot;/home/letyndr/airflow/dags&quot;,
      name=&quot;simple_example&quot;,
  )
  
  client.start(container=container.get(&quot;Id&quot;))
  
  </code></pre>
  <p>What I found was that mounting volumes only works if it's set <code>host_config</code> and <code>volumes</code>, the problem is that the implementation on Airflow just set <code>host_config</code> but not <code>volumes</code>. I added the parameter on the method <code>create_container</code>, it worked.</p>
  <p>Do you know if I'm using docker operator correctly or is this an issue?</p>