January 2018
Intermediate to advanced
414 pages
10h 29m
English
The reason we can't access the microservice when we run our previous example is that we need to expose the port that is running on the container outside of it.
So, we need to modify our Docker run command to:
docker run -d -p8080:8080 chapter07
Now we can just navigate to the URL http://localhost:8080/greetings, and we should get the following output:
hello from a Docker
We have just exposed our Docker internal port 8080, but the -p option allows us to expose a different port too. So inside, the Docker can run on port 8080, but we can externally run on another port. When we run our microservice via the command line, we actually wait until we press Ctrl + C to terminate it. We can instead just run it as a daemon.
Read now
Unlock full access