jolly-florist-66728
09/27/2024, 8:35 PMcontainer_image parameter in the task decorator. According to Flyte documentation, specifying the container_image directly in the task decorator is necessary to ensure that the custom image is used.
Here's how you can modify your task to ensure it uses the custom image:
1. Specify container_image in the task decorator: Add the container_image parameter to the task decorator to explicitly set the custom image.jolly-florist-66728
09/27/2024, 8:35 PM>>```from flytekit import task, workflow from flytekitplugins.pod.task import Pod from kubernetes.client import V1PodSpec, V1Container, V1SecurityContext import time def get_hardcoded_pod_spec() -> V1PodSpec: custom_image = "amorapprendido/flyte-gcld-dock-kube:v2" container = V1Container( name="custom-container", image=custom_image, ) pod_spec = V1PodSpec( containers=[container], restart_policy="OnFailure", security_context=V1SecurityContext(privileged=True) ) return pod_spec @task( task_config=Pod(pod_spec=get_hardcoded_pod_spec(), primary_container_name="custom-container"), container_image="amorapprendido/flyte-gcld-dock-kube:v2" ) def hardcoded_pod_task() -> str: print("Hello from the task!") time.sleep(190) print("sleep complete") return "This is a hardcoded task running in a custom container!" @workflow def main_hardcoded_pod_workflow() -> str: return hardcoded_pod_task() ``` By adding
container_image="amorapprendido/flyte-gcld-dock-kube:v2" to the task decorator, you ensure that Flyte uses your specified custom image instead of the default Flyte image.
Would you like more details on this or any other aspect of Flyte?
Sources:
- Flyte Documentation on Multiple Containers
Slack Link
https://.slack.com/archives/CP2HDHKE1/p1727469293.362139 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.