Create a service. Similar to the ``docker service create`` command. Args: image (str): The image name to use for the containers. command (list of str or str): Command to run. args (list of str): Arguments to the command. constraints (
(self, image, command=None, **kwargs)
| 148 | model = Service |
| 149 | |
| 150 | def create(self, image, command=None, **kwargs): |
| 151 | """ |
| 152 | Create a service. Similar to the ``docker service create`` command. |
| 153 | |
| 154 | Args: |
| 155 | image (str): The image name to use for the containers. |
| 156 | command (list of str or str): Command to run. |
| 157 | args (list of str): Arguments to the command. |
| 158 | constraints (list of str): :py:class:`~docker.types.Placement` |
| 159 | constraints. |
| 160 | preferences (list of tuple): :py:class:`~docker.types.Placement` |
| 161 | preferences. |
| 162 | maxreplicas (int): :py:class:`~docker.types.Placement` maxreplicas |
| 163 | or (int) representing maximum number of replicas per node. |
| 164 | platforms (list of tuple): A list of platform constraints |
| 165 | expressed as ``(arch, os)`` tuples. |
| 166 | container_labels (dict): Labels to apply to the container. |
| 167 | endpoint_spec (EndpointSpec): Properties that can be configured to |
| 168 | access and load balance a service. Default: ``None``. |
| 169 | env (list of str): Environment variables, in the form |
| 170 | ``KEY=val``. |
| 171 | hostname (string): Hostname to set on the container. |
| 172 | init (boolean): Run an init inside the container that forwards |
| 173 | signals and reaps processes |
| 174 | isolation (string): Isolation technology used by the service's |
| 175 | containers. Only used for Windows containers. |
| 176 | labels (dict): Labels to apply to the service. |
| 177 | log_driver (str): Log driver to use for containers. |
| 178 | log_driver_options (dict): Log driver options. |
| 179 | mode (ServiceMode): Scheduling mode for the service. |
| 180 | Default:``None`` |
| 181 | mounts (list of str): Mounts for the containers, in the form |
| 182 | ``source:target:options``, where options is either |
| 183 | ``ro`` or ``rw``. |
| 184 | name (str): Name to give to the service. |
| 185 | networks (:py:class:`list`): List of network names or IDs or |
| 186 | :py:class:`~docker.types.NetworkAttachmentConfig` to attach the |
| 187 | service to. Default: ``None``. |
| 188 | resources (Resources): Resource limits and reservations. |
| 189 | restart_policy (RestartPolicy): Restart policy for containers. |
| 190 | secrets (list of :py:class:`~docker.types.SecretReference`): List |
| 191 | of secrets accessible to containers for this service. |
| 192 | stop_grace_period (int): Amount of time to wait for |
| 193 | containers to terminate before forcefully killing them. |
| 194 | update_config (UpdateConfig): Specification for the update strategy |
| 195 | of the service. Default: ``None`` |
| 196 | rollback_config (RollbackConfig): Specification for the rollback |
| 197 | strategy of the service. Default: ``None`` |
| 198 | user (str): User to run commands as. |
| 199 | workdir (str): Working directory for commands to run. |
| 200 | tty (boolean): Whether a pseudo-TTY should be allocated. |
| 201 | groups (:py:class:`list`): A list of additional groups that the |
| 202 | container process will run as. |
| 203 | open_stdin (boolean): Open ``stdin`` |
| 204 | read_only (boolean): Mount the container's root filesystem as read |
| 205 | only. |
| 206 | stop_signal (string): Set signal to stop the service's containers |
| 207 | healthcheck (Healthcheck): Healthcheck |
nothing calls this directly
no test coverage detected