I see what is happening here. consul services deregister can take a service name specified via the -id= argument, or it can read the deregistration payload from a file that is specified as a positional argument.
consul services deregister shipments is doing the latter. It is trying to read a file named shipments, and is generating that error because the file does not exist.
You can resolve this by creating the file, or deregistering the service using the service ID.
Keep in mind that this command needs to be ran against the same agent where this service is registered. If you have multiple Consul agents in your environment, you can locate the appropriate agent(s) by looking at the service catalog.
$ curl --no-progress-meter $CONSUL_HTTP_ADDR/v1/catalog/service/shipments | \
jq 'map({Node: .Node, Name: .ServiceName, ID: .ServiceID})'
[
{
"Node": "test-node.example.com",
"Name": "shipments",
"ID": "shipments-1"
}
]
# Run this command against the Consul agent running on test-node
$ consul services deregister -id=shipments-1
@blake,
Thanks for an awesome explanation. That indeed was a problem, I registered service using the consul services register so there was no service file and it was complaining about it. I deregistered with id and it worked.
Thanks again for write up. I learnt something new today