Skip to content

Commit

Permalink
cleanup port binding
Browse files Browse the repository at this point in the history
  • Loading branch information
scothis committed Oct 15, 2018
1 parent 1e99306 commit 9d6762c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,20 @@ func (r *RunFlags) Run() error {
}

fmt.Println("*** RUNNING:")
fmt.Printf("Starting container listing at http://localhost:%s/\n", r.Port)
exposedPorts, portBindings, err := nat.ParsePortSpecs([]string{
fmt.Sprintf("127.0.0.1:%s:8080/tcp", r.Port),
})
if err != nil {
return err
}
ctr, err := r.Build.Cli.ContainerCreate(ctx, &container.Config{
Image: r.Build.RepoName,
AttachStdout: true,
AttachStderr: true,
ExposedPorts: nat.PortSet{
"8080/tcp": struct{}{},
},
ExposedPorts: exposedPorts,
}, &container.HostConfig{
AutoRemove: true,
PortBindings: nat.PortMap{
"8080/tcp": []nat.PortBinding{
{HostIP: "127.0.0.1", HostPort: fmt.Sprintf("%s/tcp", r.Port)},
},
},
AutoRemove: true,
PortBindings: portBindings,
}, nil, "")

// TODO cleanup signal flow
Expand All @@ -97,6 +96,7 @@ func (r *RunFlags) Run() error {
}
}()

fmt.Printf("Starting container listing at http://localhost:%s/\n", r.Port)
if err = r.Build.Cli.RunContainer(ctx, ctr.ID, r.Build.Stdout, r.Build.Stderr); err != nil && !stopped {
return errors.Wrap(err, "run built container")
}
Expand Down

0 comments on commit 9d6762c

Please sign in to comment.