github.com/portworx/docker@v1.12.1/docs/swarm/swarm-tutorial/inspect-service.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Inspect the service"
     4  description = "Inspect the application"
     5  keywords = ["tutorial, cluster management, swarm mode"]
     6  [menu.main]
     7  identifier="inspect-application"
     8  parent="swarm-tutorial"
     9  weight=17
    10  +++
    11  <![end-metadata]-->
    12  
    13  # Inspect a service on the swarm
    14  
    15  When you have [deployed a service](deploy-service.md) to your swarm, you can use
    16  the Docker CLI to see details about the service running in the swarm.
    17  
    18  1. If you haven't already, open a terminal and ssh into the machine where you
    19  run your manager node. For example, the tutorial uses a machine named
    20  `manager1`.
    21  
    22  2. Run `docker service inspect --pretty <SERVICE-ID>` to display the details
    23  about a service in an easily readable format.
    24  
    25      To see the details on the `helloworld` service:
    26  
    27      ```
    28      $ docker service inspect --pretty helloworld
    29  
    30      ID:		9uk4639qpg7npwf3fn2aasksr
    31      Name:		helloworld
    32      Mode:		REPLICATED
    33       Replicas:		1
    34      Placement:
    35      UpdateConfig:
    36       Parallelism:	1
    37      ContainerSpec:
    38       Image:		alpine
    39       Args:	ping docker.com
    40      ```
    41  
    42      >**Tip**: To return the service details in json format, run the same command
    43      without the `--pretty` flag.
    44  
    45      ```
    46      $ docker service inspect helloworld
    47      [
    48      {
    49          "ID": "9uk4639qpg7npwf3fn2aasksr",
    50          "Version": {
    51              "Index": 418
    52          },
    53          "CreatedAt": "2016-06-16T21:57:11.622222327Z",
    54          "UpdatedAt": "2016-06-16T21:57:11.622222327Z",
    55          "Spec": {
    56              "Name": "helloworld",
    57              "TaskTemplate": {
    58                  "ContainerSpec": {
    59                      "Image": "alpine",
    60                      "Args": [
    61                          "ping",
    62                          "docker.com"
    63                      ]
    64                  },
    65                  "Resources": {
    66                      "Limits": {},
    67                      "Reservations": {}
    68                  },
    69                  "RestartPolicy": {
    70                      "Condition": "any",
    71                      "MaxAttempts": 0
    72                  },
    73                  "Placement": {}
    74              },
    75              "Mode": {
    76                  "Replicated": {
    77                      "Replicas": 1
    78                  }
    79              },
    80              "UpdateConfig": {
    81                  "Parallelism": 1
    82              },
    83              "EndpointSpec": {
    84                  "Mode": "vip"
    85              }
    86          },
    87          "Endpoint": {
    88              "Spec": {}
    89          }
    90      }
    91      ]
    92      ```
    93  
    94  4. Run `docker service ps <SERVICE-ID>` to see which nodes are running the
    95  service:
    96  
    97      ```
    98      $ docker service ps helloworld
    99  
   100      ID                         NAME          SERVICE     IMAGE   LAST STATE         DESIRED STATE  NODE
   101      8p1vev3fq5zm0mi8g0as41w35  helloworld.1  helloworld  alpine  Running 3 minutes  Running        worker2
   102      ```
   103  
   104      In this case, the one instance of the `helloworld` service is running on the
   105      `worker2` node. You may see the service running on your manager node. By
   106      default, manager nodes in a swarm can execute tasks just like worker nodes.
   107  
   108      Swarm also shows you the `DESIRED STATE` and `LAST STATE` of the service
   109      task so you can see if tasks are running according to the service
   110      definition.
   111  
   112  4. Run `docker ps` on the node where the task is running to see details about
   113  the container for the task.
   114  
   115      >**Tip**: If `helloworld` is running on a node other than your manager node,
   116      you must ssh to that node.
   117  
   118      ```bash
   119      $docker ps
   120  
   121      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
   122      e609dde94e47        alpine:latest       "ping docker.com"   3 minutes ago       Up 3 minutes                            helloworld.1.8p1vev3fq5zm0mi8g0as41w35
   123      ```
   124  
   125  ## What's next?
   126  
   127  Next, you can [change the scale](scale-service.md) for the service running in
   128  the swarm.