Skip to content

Commit c9eec27

Browse files
committed
Fixed startContainer use cases
Using top command instead of true so that the container keeps running and returns the valid state
1 parent 8a6441c commit c9eec27

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/test/java/com/github/dockerjava/client/command/StartContainerCmdTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public void startContainerWithVolumes() throws DockerException {
8282
containerInspectResponse = dockerClient.inspectContainerCmd(container
8383
.getId()).exec();
8484

85+
8586
assertThat(Arrays.asList(containerInspectResponse.getVolumes()),
8687
contains(volume1, volume2));
8788

@@ -99,7 +100,7 @@ public void startContainerWithPortBindings() throws DockerException {
99100

100101
ContainerCreateResponse container = dockerClient
101102
.createContainerCmd("busybox")
102-
.withCmd("true").withExposedPorts(tcp22, tcp23).exec();
103+
.withCmd("top").withExposedPorts(tcp22, tcp23).exec();
103104

104105
LOG.info("Created container {}", container.toString());
105106

@@ -116,6 +117,8 @@ public void startContainerWithPortBindings() throws DockerException {
116117

117118
containerInspectResponse = dockerClient.inspectContainerCmd(container
118119
.getId()).exec();
120+
121+
assertThat(containerInspectResponse.getState().isRunning(), is(true));
119122

120123
assertThat(Arrays.asList(containerInspectResponse.getConfig().getExposedPorts()),
121124
contains(tcp22, tcp23));
@@ -133,7 +136,7 @@ public void startContainerWithPortBindings() throws DockerException {
133136
public void startContainer() throws DockerException {
134137

135138
ContainerCreateResponse container = dockerClient
136-
.createContainerCmd("busybox").withCmd(new String[] { "true" }).exec();
139+
.createContainerCmd("busybox").withCmd(new String[] { "top" }).exec();
137140

138141
LOG.info("Created container {}", container.toString());
139142
assertThat(container.getId(), not(isEmptyString()));

0 commit comments

Comments
 (0)