Running the Tracked Hashtag Service container

The image has been created in the previous section, so now we are able to spin up the container. The command to start the container should look like this:

docker run -d --name tracked --net twitter -p 9090:9090 springfivebyexample/tracked_hashtag

Let's explain the instruction. -d tells the Docker engine to run the container in background mode or detached.  The other important parameter is --net, which attaches the container to the desired network.

We can use the following command to tail the container logs at runtime:

docker logs tracked -f

This command is like the tail -f command on Linux, which looks at the last part of the log stream. We can remove the flag -f to see the last lines of the log. ...

Get Spring 5.0 By Example 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.