@@ -151,25 +151,45 @@ public void testImages() throws DockerException {
151151
152152 @ Test
153153 public void testListContainers () throws DockerException {
154+
155+ String testImage = "hackmann/empty" ;
156+
157+ LOG .info ("Pulling image 'hackmann/empty'" );
158+ // need to block until image is pulled completely
159+ logResponseStream (dockerClient .pull (testImage ));
160+ tmpImgs .add (testImage );
161+
154162 List <Container > containers = dockerClient .listContainers (true );
155163 assertThat (containers , notNullValue ());
156164 LOG .info ("Container List: {}" , containers );
157165
158166 int size = containers .size ();
159167
160168 ContainerConfig containerConfig = new ContainerConfig ();
161- containerConfig .setImage ("busybox" );
169+ containerConfig .setImage (testImage );
162170 containerConfig .setCmd (new String [] { "echo" });
163171
164172 ContainerCreateResponse container1 = dockerClient
165173 .createContainer (containerConfig );
174+
166175 assertThat (container1 .getId (), not (isEmptyString ()));
176+
177+ ContainerInspectResponse containerInspectResponse = dockerClient .inspectContainer (container1 .getId ());
178+
179+ assertThat (containerInspectResponse .getConfig ().getImage (), is (equalTo (testImage )));
180+
181+
167182 dockerClient .startContainer (container1 .getId ());
168183 tmpContainers .add (container1 .getId ());
169184
170185 LOG .info ("container id: " + container1 .getId ());
171186
172- List containers2 = dockerClient .listContainers (true );
187+ List <Container > containers2 = dockerClient .listContainers (true );
188+
189+ for (Container container : containers2 ) {
190+ LOG .info ("listContainer: id=" + container .getId () +" image=" + container .getImage ());
191+ }
192+
173193 assertThat (size + 1 , is (equalTo (containers2 .size ())));
174194 Matcher matcher = hasItem (hasField ("id" , startsWith (container1 .getId ())));
175195 assertThat (containers2 , matcher );
@@ -179,12 +199,12 @@ public void testListContainers() throws DockerException {
179199 assertThat (filteredContainers .size (), is (equalTo (1 )));
180200
181201 for (Container container : filteredContainers ) {
182- LOG .info ("container : " + container );
202+ LOG .info ("filteredContainer : " + container . getImage () );
183203 }
184204
185205 Container container2 = filteredContainers .get (0 );
186206 assertThat (container2 .getCommand (), not (isEmptyString ()));
187- assertThat (container2 .getImage (), equalTo ("busybox :latest" ));
207+ assertThat (container2 .getImage (), equalTo (testImage + " :latest" ));
188208 }
189209
190210 /*
@@ -232,7 +252,7 @@ public void testStartContainer() throws DockerException {
232252 assertThat (containerInspectResponse .getId (),
233253 startsWith (container .getId ()));
234254
235- assertThat (containerInspectResponse .getImage (), not (isEmptyString ()));
255+ assertThat (containerInspectResponse .getImageId (), not (isEmptyString ()));
236256 assertThat (containerInspectResponse .getState (), is (notNullValue ()));
237257
238258 assertThat (containerInspectResponse .getState ().running , is (true ));
0 commit comments