github.com/moby/docker@v26.1.3+incompatible/client/container_top.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "encoding/json" 6 "net/url" 7 "strings" 8 9 "github.com/docker/docker/api/types/container" 10 ) 11 12 // ContainerTop shows process information from within a container. 13 func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (container.ContainerTopOKBody, error) { 14 var response container.ContainerTopOKBody 15 query := url.Values{} 16 if len(arguments) > 0 { 17 query.Set("ps_args", strings.Join(arguments, " ")) 18 } 19 20 resp, err := cli.get(ctx, "/containers/"+containerID+"/top", query, nil) 21 defer ensureReaderClosed(resp) 22 if err != nil { 23 return response, err 24 } 25 26 err = json.NewDecoder(resp.body).Decode(&response) 27 return response, err 28 }