Ruslan Aliev
09/23/2021, 12:36 PMlocal agent
and try to bind local folder with folder inside docker container using volumes
, but looks like it doesn’t work or I do it wrong 👀:
container_name = StringFormatter(name="Container name", template="scenario_{scenario_id}_task_{task_id}")
container_id = create_container(image_name=image_name,
container_name=container_name(scenario_id=scenario_id, task_id=task_id),
# command=command,
command=['ls'],
volumes=['data:/home/data',
'temp:/home/temp'],
).set_upstream(input_file_path)
started = start_container(container_id=container_id)
status_code = wait_on_container(container_id=container_id, upstream_tasks=[started])
logs = get_container_logs(container_id=container_id, upstream_tasks=[status_code])
log([logs])
The log([logs])
shows, that the data
and temp
folders are missed.
What am I missing here?Kevin Kho
Kevin Kho
Ruslan Aliev
09/24/2021, 1:02 PMhost_config
to prefect.tasks.docker.containers.CreateContainer
, but on run got that error:
TypeError: __init__() got an unexpected keyword argument 'NetworkMode'
But your code snippet works fine - thank you!
I don’t know why host_config
didn’t work correctly with Prefect CreateContainer
.Kevin Kho
Kevin Kho
Ruslan Aliev
09/28/2021, 11:05 AMdocker -v
Docker version 20.10.8, build 3967b7d
Python packages:
prefect.__version__ = '0.15.5'
docker.__version__ = '5.0.0'
Flow code:
https://gist.github.com/RuslanTau/b184386aad252d1a46a7bc3f98c3f36fKevin Kho
CreateContiner
takes in a dict
for host_config. You actually created a host_config and passed it. That Prefect task will take care of handling it. Can you try:
host_config = {"binds": absolute_volumes}
Ruslan Aliev
09/29/2021, 8:49 AMhost_config = {"binds": absolute_volumes}
works fine - thank you!
It took me a while to figure out why you hand over the key “binds” instead “Binds”, which I get by create_host_config
method 🙃Kevin Kho