You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Caleb M Keller (JIRA)" <ji...@apache.org> on 2019/01/09 15:33:00 UTC

[jira] [Commented] (AIRFLOW-2891) Option to set container_name for DockerOperator

    [ https://issues.apache.org/jira/browse/AIRFLOW-2891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16738340#comment-16738340 ] 

Caleb M Keller commented on AIRFLOW-2891:
-----------------------------------------

I believe the easiest way to accomplish this would be to add a rename to the container if the name option is specified. Something like:
{code:java}
self.container = self.cli.create_container(
  command=self.get_command(),
  environment=self.environment,
  host_config=self.cli.create_host_config(
    auto_remove=self.auto_remove,
    binds=self.volumes,
    network_mode=self.network_mode,
    shm_size=self.shm_size,
    dns=self.dns,
    dns_search=self.dns_search,
    cpu_shares=int(round(self.cpus * 1024)),
    mem_limit=self.mem_limit),
  image=self.image,
  user=self.user,
  working_dir=self.working_dir
)

if self.name:
  self.cli.rename(self.conatiner['Id'], self.name)

self.cli.start(self.container['Id'])
{code}
[here are the docs on rename|https://docker-py.readthedocs.io/en/stable/api.html#docker.api.container.ContainerApiMixin.rename].

I may try to get the PR in.

> Option to set container_name for DockerOperator
> -----------------------------------------------
>
>                 Key: AIRFLOW-2891
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-2891
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: docker, operators
>            Reporter: Wouter Menninga
>            Priority: Minor
>
> It would be nice if the name of a Docker container created using the {{DockerOperator}} could be specified by passing it as an argument to {{DockerOperator}}, instead of having Docker generate its random name for the container.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)