The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

john_seattle (17) [Avatar] Offline
#1
Issue: On run of compiled jar in docker, when trying to access the docker
web page I'm getting weird characters written to screen.

Hopefully I'm doing things correctly. Docker is new for me. Running
tomcat applications is not new for me. Spring boot is fairly new for me.
And I'm using Docker from a Windows environment.

I'm starting to go through the code, starting with chapter 1. I have
installed docker. I'm able to run docker quick start shell/window. I
have built the code from the chapter 1 sub-directory and, NOT using
Docker, I can run the compiled jar file, and using:

http://localhost:8080/hello/first/last

from a browser I can see the expected output on resulting browser page.
So far, so good.

I have followed the readme instructions in the chapter 1 directory.
Building of the application within docker window seems okay. Running
the application using docker-compose seems to okay too - I'm getting
"Tomcat started on port(s): 8080 (http)" in the docker window.

I had a problem finding how to access the application from outside
of the docker environment using firefox or other browser. From my research,
I found that I could not use localhost:8080 but need to access the docker
shell's ip and port. Within a docker window I use "docker ps" to see the
application running, and use "docker-machine ls" to get the ip and port, for
instance:

URL tcp://192.160.99.100:2376 , is returned as part of the command result.

Therefore, I'm using in a browser window this address to access the
application:

http://192.160.99.100:2376/hello/first/last

I'm not getting a HTTP not found error but I'm getting some weird characters,
a few weird graphical characters right away on the browser window. As the
application returns a page quickly and I don’t get any error, this seems to me
that I'm accessing the application correctly using the above url. But, I may be
mistaken.

Do you have a suggestion as to help with accessing the application from
a browser outside of docker and to resolve this weird result?

-John from Seattle
john_seattle (17) [Avatar] Offline
#2
To anyone interested, I found that I was close with my explanation
and analysis to my problem. Here's the commands to use and process
to access a docker containerized web application & web page:

1) Per the author's readme file, in a Docker Quickstart window, using the
command to run the docker-ized application:

"docker-compose -f docker/common/docker-compose.yml up"

You will see the somewhere near the bottom of Docker's listing something
like the following:

"Tomcat started on port(s): 8080 (http)"

So 8080 is the port to use.

2) With the application running in one Docker window, open another Docker
Quickstart window. Enter "docker ps" to see your application running, you
should see as the

"Image": "johncarnell/tmx-simple-service:chapter1"

So we know the application is running.

3) Enter "docker-machine ls" to see the URL of the running app's container
address, for me it displayed:

"tcp://192.168.99.100:2376"

Note that this is the address to use, but we need to use "8080" for the port not
"2376" that I had previously used. We now have the url and port to access the
application.

4) From a browser enter: "http://192.168.99.100:8080/hello/first/last" to display
the application's output:

" {"message":"Hello first last"} "

Success!
~ I think that you can also use some variant of "docker inspect" to get the
url and port, but I could not get that to work.


- John from Seattle

John C Carnell (44) [Avatar] Offline
#3
Hi John,

Just a quick question are you using the latest code and version of the chapter. The URL you are accessing is for Docker Machine. (http://192.168.99.100:8080/hello/first/last). I used Docker Machine in an early version of the book but moved away from it once Docker 1.12 became available. (Native to OS X and Windows now). So if you could tell me where you got that URL I will double check to make sure it gets cleaned up in the final version of the book.

Thanks,
John Carnell (in Cary, North Carolina smilie)
john_seattle (17) [Avatar] Offline
#4
John,

I have installed Docker Toolbox, Docker version 17.05.0-ce. I running
this on a Windows 8 cpu. About the URL, I looked at the application code
for this, I believe. BTW, Docker is totally new for me. I'll check the source
code. I appreciate your book very much, and "Spring Boot in Action" too.
I look forward to your book's final release. I hope this helps.

-John W. from Seattle
vyurik (76) [Avatar] Offline
#5
Hi John from Seattle,
My laptop is Windows 10 Home and when I installed Docker I was denied with Hystrix download and ended up with the Docker Toolbox.
As you said in your last message, you are using the Docker Toolbox.
My question is: are able to build/run all application in the book with Docker Toolbox?
The reason for this question is that I have exceptions while running Chapter 7 docker-compose -f docker/common/docker-compose.yml up command.
I'll post a separate message on this exception.
Thanks,
Vitaly
vyurik (76) [Avatar] Offline
#6
vyurik wrote:Hi John from Seattle,
My laptop is Windows 10 Home and when I installed Docker I was denied with HyperV download and ended up with the Docker Toolbox.
As you said in your last message, you are using the Docker Toolbox.
My question is: are able to build/run all application in the book with Docker Toolbox?
The reason for this question is that I have exceptions while running Chapter 7 docker-compose -f docker/common/docker-compose.yml up command.
I'll post a separate message on this exception.
Thanks,
Vitaly