docker service inspect --pretty should show secrets/configs
Create a service using a secret and a config:
echo "bla" | docker config create foo.conf -
echo "bla" | docker secret create secret.conf -
docker service create -d \
--config source=foo.conf,target=/foo.conf,uid=123,gid=456 \
--secret source=secret.conf,target=/secret.conf,uid=234,gid=567 \
--replicas 1 \
--name myservice \
nginx:alpine
Inspect the service with the --pretty option:
docker service inspect myservice --pretty
ID: ib7yble4rm5qbz3ijmk83cxeh
Name: myservice
Service Mode: Replicated
Replicas: 1
Placement:
UpdateConfig:
Parallelism: 1
On failure: pause
Monitoring Period: 5s
Max failure ratio: 0
Update order: stop-first
RollbackConfig:
Parallelism: 1
On failure: pause
Monitoring Period: 5s
Max failure ratio: 0
Rollback order: stop-first
ContainerSpec:
Image: nginx:alpine@sha256:48947591194ac5a9dce1e110f9198a547debb21630f121081640b87d99ca8b11
Resources:
Endpoint Mode: vip
Notice that no information about the configs or secrets is printed.
Inspect the service without --pretty:
docker service inspect myservice
[
{
"ID": "ib7yble4rm5qbz3ijmk83cxeh",
"Version": {
"Index": 776
},
"CreatedAt": "2018-02-28T09:42:57.612406537Z",
"UpdatedAt": "2018-02-28T09:42:57.612406537Z",
"Spec": {
"Name": "myservice",
"Labels": {},
"TaskTemplate": {
"ContainerSpec": {
"Image": "nginx:alpine@sha256:48947591194ac5a9dce1e110f9198a547debb21630f121081640b87d99ca8b11",
"StopGracePeriod": 10000000000,
"DNSConfig": {},
"Secrets": [
{
"File": {
"Name": "/secret.conf",
"UID": "234",
"GID": "567",
"Mode": 292
},
"SecretID": "yv9vtn86nugxsbshu1ccumlod",
"SecretName": "secret.conf"
}
],
"Configs": [
{
"File": {
"Name": "/foo.conf",
"UID": "123",
"GID": "456",
"Mode": 292
},
"ConfigID": "j915gbt419wv9022nr2w8pqdh",
"ConfigName": "foo.conf"
}
],
"Isolation": "default"
},
"Resources": {
"Limits": {},
"Reservations": {}
},
"RestartPolicy": {
"Condition": "any",
"Delay": 5000000000,
"MaxAttempts": 0
},
"Placement": {
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux"
},
{
"Architecture": "arm64",
"OS": "linux"
},
{
"Architecture": "386",
"OS": "linux"
},
{
"Architecture": "ppc64le",
"OS": "linux"
},
{
"Architecture": "s390x",
"OS": "linux"
}
]
},
"ForceUpdate": 0,
"Runtime": "container"
},
"Mode": {
"Replicated": {
"Replicas": 1
}
},
"UpdateConfig": {
"Parallelism": 1,
"FailureAction": "pause",
"Monitor": 5000000000,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"RollbackConfig": {
"Parallelism": 1,
"FailureAction": "pause",
"Monitor": 5000000000,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"EndpointSpec": {
"Mode": "vip"
}
},
"Endpoint": {
"Spec": {}
}
}
]
Notice that information about secrets and configs is present, so this would be an easy change (just adjusting the template for --pretty)
Hi I have taken a look into this bug and I noticed the pretty template can be found here: https://github.com/docker/cli/blob/c0ffb9491cdffb628e18bb491b566255987fd28d/cli/command/formatter/service.go#L19-L129
I traced the Raw template to the https://github.com/docker/cli/blob/c0ffb9491cdffb628e18bb491b566255987fd28d/cli/command/formatter/formatter.go#L64 file and I believe the logic is stored within one of the functions within the parseFormat() function.
Is my assumption accurate? If not where do you suggest looking?
Yes, I think that sounds about right; if you’re interested to work on this, that’d be great!
I am definitely interested in working on this and thank you for the reassurance. I am fairly new to contributing to Docker and was wondering how should i go about testing the inspect command changes I would make. Do I need to clone the repository and debug in visual studio code? Or do I need to run some scripts such as the ones in the MakeFile?
The easiest way to build is to use the docker.Makefile; that will build the source in a container (but bind-mounts the source, so that you can edit using your preferred editor), for example;
make -f docker.Makefile binary shell
Will build the CLI from source and starts an interactive container in which you can try the binary you built
Thank you so much for the advice.
@thaJeztah the issue was not close and I can't see a pr for it, should I assume I can work on it?
shouldn't this issue be closed?
is there any update regarding to this issue ? @thaJeztah Seems something merged which points this issue.
Thank you so much for the advice.
HI, I made a change to this code and also have a suggestion too. kindly go through my changes, don't mind the way I type. Thanks. @thaJeztah
Guess the Issue can be closed, right?
Running docker service inspect _service_ --pretty show the desired informations
on the latest Version 20.10.7
I come from https://github.com/MunGell/awesome-for-beginners#go and find this issue. I think this can be closed so no more people come to this and realize this is an issue they can tackle but it's already solved.
Running docker service inspect _service_ --pretty and it's showing desired information
on Version 20.10. 16 as well now. Can we close this?