Before pushing the image to the public repository, you should make sure that it is working as expected. First, we’ll want to identify that the image exists and then start up the container to see if the Spring Boot application behaves as expected. For now, we’ll just run the plain Docker commands.
images command lists the available images. Alternatively, you can also create a task of type
DockerListImages in your build script.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
bmuschko/account-web-service 1.0.0 91db93d1be41 5 days ago 98.5MB
Great, the image is available for consumption. Next, you will start a container for the image. You start a container with the
run command. The command renders the container ID in the console for future reference.
$ docker run -d -p 8080:8080 bmuschko/account-web-service:1.0.0
The Docker plugin also supports task types for creating, starting and stopping containers. However, it makes more sense to explain the task types with the help of a more specific use case (covered in the next blog post).
You can also discover all running containers by listing them with the
container ls command.
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
670757d71ccc bmuschko/account-web-service:1.0.0 "java -jar /app/acco…" 32 minutes ago Up 32 minutes (healthy) 0.0.0.0:8080->8080/tcp angry_einstein
The application is ready for use as soon as the status turns "healthy". In practice that means that the
curl command could successfully resolve the URL in the Dockerfile. We can verify one of the application’s endpoints by calling the URL
http://localhost:8080/accounts?id=1 in a browser. The HTTP response returns a JSON structure representing a bank account.
We know that the application works properly within a Docker container. Next, you will push the image for consumption by other users.