Skip to content

Commit 7e7ade8

Browse files
Fix IRB container package
- implement docker API changes Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
1 parent 0af7194 commit 7e7ade8

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

samples/demos/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ include $(TOP)/build.mk
88

99
DEMOS = irb
1010

11-
build clean:
11+
build test clean:
1212
$(foreach DIR, $(DEMOS), $(MAKE) -C $(DIR) $@ || exit;)
1313

samples/demos/irb/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(TOP)/build.mk
77

88
COMPONENTS = protos chaincode experimenter
99

10-
all: pull-images ercc build test
10+
all: ercc build test
1111

1212
pull-images:
1313
$(DOCKER) pull redis:latest
@@ -23,7 +23,7 @@ ercc:
2323
build: ercc
2424
$(foreach DIR, $(COMPONENTS), $(MAKE) -C $(DIR) $@ || exit;)
2525

26-
test:
26+
test: pull-images
2727
$(GO) test -v ./...
2828

2929
run:

samples/demos/irb/pkg/container/container.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)