Remote API for docker exec commands

前端 未结 2 1570
青春惊慌失措
青春惊慌失措 2020-12-20 01:20

Could someone please help me with remote api for docker exec to run a command?

I am able to run it directly:

# docker exec 941430a3060c date
Fri Apr          


        
2条回答
  •  忘掉有多难
    2020-12-20 02:10

    The API section which would help you is: Exec Create/Start

    You can see some example in integration-cli/docker_api_exec_test.go

    • create:

      sockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": []string{"true"}})
      
    • start:

      sockRequestRaw("POST", fmt.Sprintf("/exec/%s/start", id), strings.NewReader(`{"Detach": true}`), "application/json")
      
    • inspect:

      sockRequestRaw("GET", fmt.Sprintf("/exec/%s/json", id), nil, "")
      

提交回复
热议问题