Starting and stopping containers

To start-up the container, execute the following:

$ mvn clean package docker:start  

Maven will build our REST service from source, build the image and start up the container in the background. As the output, we will be given the ID of the container, as you can see on the following screenshot:

The container is now running in the background. To test if it's running, we could issue a docker ps to list all the running containers, or just call the service by executing some HTTP methods such as GET or POST on the mapped 8080 port. The port has been exposed in the<build> configuration element and exposed in the

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.