github.com/clly/consul@v1.4.5/website/source/docs/commands/services/deregister.html.markdown.erb (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Commands: Services Deregister"
     4  sidebar_current: "docs-commands-services-deregister"
     5  ---
     6  
     7  # Consul Agent Service Deregistration
     8  
     9  Command: `consul services deregister`
    10  
    11  The `services deregister` command deregisters a service with the local agent.
    12  Note that this command can only deregister services that were registered
    13  with the agent specified (defaults to the local agent) and is meant to
    14  be paired with `services register`.
    15  
    16  This is just one method for service deregistration. If the service was
    17  registered with a configuration file, then deleting that file and
    18  [reloading](/docs/commands/reload.html) Consul is the correct method to
    19  deregister. See [Service Definition](/docs/agent/services.html) for more
    20  information about registering services generally.
    21  
    22  ## Usage
    23  
    24  Usage: `consul services deregister [options] [FILE...]`
    25  
    26  This command can deregister either a single service using the `-id` flag
    27  documented below, or one or more services using service definition files
    28  in HCL or JSON format.
    29  This flexibility makes it easy to pair the command with the
    30  `services register` command since the argument syntax is the same.
    31  
    32  #### API Options
    33  
    34  <%= partial "docs/commands/http_api_options_client" %>
    35  
    36  #### Service Deregistration Flags
    37  
    38  The flags below should only be set if _no arguments_ are given. If no
    39  arguments are given, the flags below can be used to deregister a single
    40  service.
    41  
    42  * `-id` - The ID of the service.
    43  
    44  ## Examples
    45  
    46  To deregister by ID:
    47  
    48  ```text
    49  $ consul services deregister -id=web
    50  ```
    51  
    52  To deregister from a configuration file:
    53  
    54  ```text
    55  $ cat web.json
    56  {
    57    "Service": {
    58      "Name": "web"
    59    }
    60  }
    61  
    62  $ consul services deregister web.json
    63  ```