BretFisher/node-docker-good-defaults

Back to basics... Problem using $ docker build / $ docker run. No browser function.

zipzit opened this issue · 4 comments

Bret, this is a pretty awesome project, and I'm really trying to put it to good use. There is something I just don't understand.

If I do a pure clone of the project, and then attempt to build and run a container using $ docker, I can't see the server on localhost. It works fine using $ docker-compose.
Am I doing this correctly?

  1. Clone the repo.
  2. $ docker build -t <yourWebAppName> . # -t flag tag the image with a custom name
    $ docker run <yourWebAppName>
  3. I can't find the port anywhere. The terminal shows things apparently running. But the browser is totally dead at localhost:80, localhost:8080, etc... I can see all the healthz 200 requests in the terminal.
    $ docker ps -a ## identify running container
    $ docker port running_container_hash returns null
  4. close all the containers, remove all docker images and containers for fresh new start
  5. $ docker-compose up
  6. $ docker port <hash> returns as expected. http://localhost in the browser works fine.
80/tcp -> 0.0.0.0:80
9229/tcp -> 0.0.0.0:9229
5858/tcp -> 0.0.0.0:5858

I'm hoping to use your simple repo to do A-B-A testing between $ docker build / run and $ docker-compose. I'd like to input a tiny bit of data on the console and I'm having troubles with docker-compose.yml methods. I'm trying to understand how the interactive modes work with Docker. The fact that I can't see localhost when I $ docker build/run makes me nervous. Am I doing this right?

Note: I'm running the mac version of docker. I'm running everything in the command line. Not using any IDE or Kitematic for anything.

Again, many thanks to you for the work (and documentation) you've done on this project.

--LB

Oops. My bad, way bad.

$ docker run -p 8080:80 <yourWeAppName> # Got to add the port for command line docker run.

Profuse apologies.. Please close. I'm still not thinking about the differences between writing images but running containers. EXPOSE ports is only half of the conversation.

no worries @zipzit but ideally for local dev you're using docker-compose cli which is much easier with the docker-compose.yml then raw docker commands. docker-compose up will open the local port and much more.

Good info, thanks for documenting it.