@@ -11,7 +11,6 @@ import (
1111 "context"
1212 "fmt"
1313
14- "github.com/docker/docker/api/types"
1514 "github.com/docker/docker/api/types/container"
1615 "github.com/docker/docker/client"
1716 "github.com/docker/go-connections/nat"
@@ -40,12 +39,10 @@ func (c *Container) Start() error {
4039 Image : c .Image ,
4140 Cmd : c .CMD ,
4241 Env : c .Env ,
43- },
44- & container.HostConfig {
45- PortBindings : nat.PortMap {
46- nat .Port (fmt .Sprintf ("%s/tcp" , c .HostPort )): []nat.PortBinding {{HostIP : c .HostIP , HostPort : c .HostPort }},
42+ ExposedPorts : nat.PortSet {
43+ nat .Port (c .HostPort + "/tcp" ): struct {}{},
4744 },
48- }, nil , nil , c .Name )
45+ }, nil , nil , nil , c .Name )
4946 if err != nil {
5047 return err
5148 }
@@ -54,12 +51,12 @@ func (c *Container) Start() error {
5451 return err
5552 }
5653
57- if err := cli .ContainerStart (ctx , resp .ID , types. ContainerStartOptions {}); err != nil {
54+ if err := cli .ContainerStart (ctx , resp .ID , container. StartOptions {}); err != nil {
5855 return err
5956 }
6057
6158 go func () {
62- reader , err := cli .ContainerLogs (context .Background (), resp .ID , types. ContainerLogsOptions {
59+ reader , err := cli .ContainerLogs (context .Background (), resp .ID , container. LogsOptions {
6360 ShowStdout : true ,
6461 ShowStderr : true ,
6562 Follow : true ,
@@ -93,11 +90,12 @@ func (c *Container) Stop() error {
9390 return err
9491 }
9592
93+ // default timeout is 10s
9694 if err := cli .ContainerStop (ctx , c .containerID , container.StopOptions {}); err != nil {
9795 return err
9896 }
9997
100- if err := cli .ContainerRemove (ctx , c .containerID , types. ContainerRemoveOptions {}); err != nil {
98+ if err := cli .ContainerRemove (ctx , c .containerID , container. RemoveOptions {}); err != nil {
10199 return err
102100 }
103101
0 commit comments