class Docker::API::Service
This class represents the Docker
API endpoints regarding services.
Services are the definitions of tasks to run on a swarm. Swarm mode must be enabled for these endpoints to work. @see docs.docker.com/engine/api/v1.40/#tag/Service
Public Instance Methods
Create a service
Docker
API: POST /services/create @see docs.docker.com/engine/api/v1.40/#operation/ServiceCreate
@param body [Hash]: Request body to be sent as json. @param authentication [Hash]: Authentication parameters.
# File lib/docker/api/service.rb, line 24 def create body = {}, authentication = {} headers = {"Content-Type": "application/json"} headers.merge!({"X-Registry-Auth" => auth_encoder(authentication) }) if authentication.keys.size > 0 @connection.request(method: :post, path: "/services/create", headers: headers, body: body.to_json) end
Delete a service
Docker
API: DELETE /services/{id} @see docs.docker.com/engine/api/v1.40/#operation/ServiceDelete
@param name [String]: The ID or name of the service.
# File lib/docker/api/service.rb, line 74 def delete name @connection.delete("/services/#{name}") end
Inspect a service
Docker
API: GET /services/{id} @see docs.docker.com/engine/api/v1.40/#operation/ServiceInspect
@param name [String]: The ID or name of the service. @param params [Hash]: Parameters that are appended to the URL.
# File lib/docker/api/service.rb, line 53 def details name, params = {} @connection.get(build_path("/services/#{name}", params)) end
List services
Docker
API: GET /services @see docs.docker.com/engine/api/v1.40/#operation/ServiceList
@param params [Hash]: Parameters that are appended to the URL.
# File lib/docker/api/service.rb, line 13 def list params = {} @connection.get(build_path("/services", params)) end
Get stdout and stderr logs from a service.
Docker
API: GET /services/{id}/logs @see docs.docker.com/engine/api/v1.40/#operation/ServiceLogs
@param name [String]: The ID or name of the service. @param params [Hash]: Parameters that are appended to the URL.
# File lib/docker/api/service.rb, line 64 def logs name, params = {} @connection.get(build_path("/services/#{name}/logs", params)) end
Update a service
Docker
API: POST /services/{id}/update @see docs.docker.com/engine/api/v1.40/#operation/ServiceUpdate
@param name [String]: The ID or name of the service. @param params [Hash]: Parameters that are appended to the URL. @param body [Hash]: Request body to be sent as json. @param authentication [Hash]: Authentication parameters.
# File lib/docker/api/service.rb, line 39 def update name, params = {}, body = {}, authentication = {} # view https://github.com/docker/swarmkit/issues/1394#issuecomment-240850719 headers = {"Content-Type": "application/json"} headers.merge!({"X-Registry-Auth" => auth_encoder(authentication) }) if authentication.keys.size > 0 @connection.request(method: :post, path: build_path("/services/#{name}/update", params), headers: headers, body: body.to_json) end