github.com/moby/docker@v26.1.3+incompatible/client/container_rename.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "net/url" 6 ) 7 8 // ContainerRename changes the name of a given container. 9 func (cli *Client) ContainerRename(ctx context.Context, containerID, newContainerName string) error { 10 query := url.Values{} 11 query.Set("name", newContainerName) 12 resp, err := cli.post(ctx, "/containers/"+containerID+"/rename", query, nil, nil) 13 ensureReaderClosed(resp) 14 return err 15 }