(name string, ports map[string]int, opts StartOptions)
| 267 | } |
| 268 | |
| 269 | func (e *DockerEnvironment) buildDockerRunArgs(name string, ports map[string]int, opts StartOptions) []string { |
| 270 | args := []string{"--rm", "--net=" + e.networkName, "--name=" + dockerNetworkContainerHost(e.networkName, name), "--hostname=" + name} |
| 271 | |
| 272 | // Mount the docker env working directory into the container. It's shared across all containers to allow easier scenarios. |
| 273 | args = append(args, "-v", fmt.Sprintf("%s:%s:z", e.dir, e.dir)) |
| 274 | |
| 275 | for _, v := range e.dockerVolumes { |
| 276 | args = append(args, "-v", v) |
| 277 | } |
| 278 | |
| 279 | for _, v := range opts.Volumes { |
| 280 | args = append(args, "-v", v) |
| 281 | } |
| 282 | |
| 283 | // Environment variables |
| 284 | for name, value := range opts.EnvVars { |
| 285 | args = append(args, "-e", name+"="+value) |
| 286 | } |
| 287 | |
| 288 | if opts.User != "" { |
| 289 | args = append(args, "--user", opts.User) |
| 290 | } |
| 291 | |
| 292 | if opts.UserNs != "" { |
| 293 | args = append(args, "--userns", opts.UserNs) |
| 294 | } |
| 295 | |
| 296 | if opts.Privileged { |
| 297 | args = append(args, "--privileged") |
| 298 | } |
| 299 | |
| 300 | for _, c := range opts.Capabilities { |
| 301 | args = append(args, "--cap-add", string(c)) |
| 302 | } |
| 303 | |
| 304 | if opts.LimitMemoryBytes > 0 { |
| 305 | args = append(args, "--memory", fmt.Sprintf("%db", opts.LimitMemoryBytes)) |
| 306 | } |
| 307 | |
| 308 | if opts.LimitCPUs > 0 { |
| 309 | args = append(args, "--cpus", fmt.Sprintf("%f", opts.LimitCPUs)) |
| 310 | } |
| 311 | |
| 312 | // Published ports. |
| 313 | for _, port := range ports { |
| 314 | args = append(args, "-p", strconv.Itoa(port)) |
| 315 | } |
| 316 | |
| 317 | // Disable entrypoint if required. |
| 318 | if opts.Command.EntrypointDisabled { |
| 319 | args = append(args, "--entrypoint", "") |
| 320 | } |
| 321 | |
| 322 | args = append(args, opts.Image) |
| 323 | if opts.Command.Cmd != "" { |
| 324 | args = append(args, opts.Command.Cmd) |
| 325 | } |
| 326 | if len(opts.Command.Args) > 0 { |
no test coverage detected