MCPcopy Create free account
hub / github.com/fsouza/go-dockerclient / createExecContainer

Method createExecContainer

testing/server.go:1163–1203  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

1161}
1162
1163func (s *DockerServer) createExecContainer(w http.ResponseWriter, r *http.Request) {
1164 id := mux.Vars(r)["id"]
1165 container, err := s.findContainer(id)
1166 if err != nil {
1167 http.Error(w, err.Error(), http.StatusNotFound)
1168 return
1169 }
1170
1171 execID := s.generateID()
1172 s.cMut.Lock()
1173 container.ExecIDs = append(container.ExecIDs, execID)
1174 s.cMut.Unlock()
1175
1176 exec := docker.ExecInspect{
1177 ID: execID,
1178 ContainerID: container.ID,
1179 }
1180
1181 var params docker.CreateExecOptions
1182 err = json.NewDecoder(r.Body).Decode(&params)
1183 if err != nil {
1184 http.Error(w, err.Error(), http.StatusInternalServerError)
1185 return
1186 }
1187 if len(params.Cmd) > 0 {
1188 exec.ProcessConfig.EntryPoint = params.Cmd[0]
1189 if len(params.Cmd) > 1 {
1190 exec.ProcessConfig.Arguments = params.Cmd[1:]
1191 }
1192 }
1193
1194 exec.ProcessConfig.User = params.User
1195 exec.ProcessConfig.Tty = params.Tty
1196
1197 s.execMut.Lock()
1198 s.execs = append(s.execs, &exec)
1199 s.execMut.Unlock()
1200 w.WriteHeader(http.StatusOK)
1201 w.Header().Set("Content-Type", "application/json")
1202 json.NewEncoder(w).Encode(map[string]string{"Id": exec.ID})
1203}
1204
1205func (s *DockerServer) startExecContainer(w http.ResponseWriter, r *http.Request) {
1206 id := mux.Vars(r)["id"]

Callers

nothing calls this directly

Calls 5

findContainerMethod · 0.95
generateIDMethod · 0.95
DecodeMethod · 0.80
SetMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected