inspect a service on the swarm

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了inspect a service on the swarm相关的知识,希望对你有一定的参考价值。

当你在一个swarm 中部署了一个服务,你可以通过以下的命令行语句来查看集群中运行的服务的详细信息

docker service inspect --pretty <SERVICE-ID>


$docker machine ssh manager1

查看helloworld 服务的详细信息
$ docker service inspect --pretty helloworld
ID:9uk4639qpg7npwf3fn2aasksr
Name:helloworld
Service Mode:REPLICATED
 Replicas:1
Placement:
UpdateConfig:
 Parallelism:1
ContainerSpec:
 Image:alpine
 Args:ping docker.com
Resources:
Endpoint Mode:  vip


如果需要返回的信息是json格式,只需要不带 --pretty 参数即可

$ docker service inspect helloworld
[
{
    "ID": "9uk4639qpg7npwf3fn2aasksr",
    "Version": {
        "Index": 418
    },
    "CreatedAt": "2016-06-16T21:57:11.622222327Z",
    "UpdatedAt": "2016-06-16T21:57:11.622222327Z",
    "Spec": {
        "Name": "helloworld",
        "TaskTemplate": {
            "ContainerSpec": {
                "Image": "alpine",
                "Args": [
                    "ping",
                    "docker.com"
                ]
            },

     

      "Resources": {
                "Limits": {},
                "Reservations": {}
  },
            "RestartPolicy": {
                "Condition": "any",
                "MaxAttempts": 0
            },
            "Placement": {}
        },
        "Mode": {
            "Replicated": {
                "Replicas": 1
            }
        },
        "UpdateConfig": {
            "Parallelism": 1
        },
        "EndpointSpec": {
            "Mode": "vip"
        }
    },
    "Endpoint": {
        "Spec": {}
    }
}
]


查看哪个节点运行helloworld服务

docker service ps <SERVICE-ID>

$ docker service ps helloworld
NAME                                    IMAGE   NODE     DESIRED STATE  LAST STATE
helloworld.1.8p1vev3fq5zm0mi8g0as41w35  alpine  worker2  Running        Running 3 minutes


本文出自 “清风柳絮” 博客,请务必保留此出处http://binuu.blog.51cto.com/801317/1942337

以上是关于inspect a service on the swarm的主要内容,如果未能解决你的问题,请参考以下文章

Creating a keytab file for the Kerberos service account (using the ktutil command on Linux)

Redirect the Output of systemd Service to a File

The show must go on: Fundamental data plane connectivity services for dependable SDNs

The listener supports no services

the service mysql57 failed the most

(转)inspect — Inspect live objects