Docker - from the beginning, part I

Chris Noring on February 20, 2019

Follow me on Twitter, happy to take your suggestions on topics or improvements /Chris This article is part of a series: Docker — from the beginn... [Read Full]
markdown guide
 

Well written Chris. I like seeing more people writing tutorials like a conversation 😊😊

 

Fantastic article! I really love when I can learn and also try a real example! :)

In my case, I had some problems with the port, to make it work I had to modify my Dockerfile in this way:

EXPOSE ${PORT}

Without using curly brackets, the port wasn't available inside the Nodejs file. Do you know why? I'm using Docker 2.0.0.3 (31259) for macOS.

 

Hi Chris, why are we specifying 'from/node' when we've already been explicit in the Dockerfile about which os to build from?

 

hi Eugene. I'm trying to understand what you mean? where are you seeing this ?

 

Hi Chris, I was wondering the same thing... the Dockerfile starts with:

FROM node:latest

and the image building command is:

docker build -t chrisnoring/node:latest .

So why you needed to specify node:latest twice?
Thanks!!

Yes thank you for taking the time to be more specific, this is exactly what I was referring to. I've tried without the /node:latest and it produces the same result because of the Dockerfile having that specified.

I could be wrong here, but I think you can call it what you want in the docker build command.. so it could be
FROM node:latest
in Dockerfile and
docker build -t chrisnoring/node:dev
It's just a way to give different builds different names.

 

For Windows Docker, use the docker-machine ip instead of localhost - use the command docker-machine ip

$docker-machine ip
192.168.99.101 <-- use this ip address

192.168.99.101:8000

 

This is only applicable if one is using docker toolbox on windows.
If someone is using docker for windows, it will bind to localhost as in the tutorial.

 

Thanks for this usefull part.
Isn't it a missing line in the Dockerfile ?

RUN npm install express

 

hi. Because we at an earlier stage ran npm install --save at our terminal, our express library is now part of package.json. So all we need in our Dockerfile is RUN npm install, that will install everything listed in "dependencies" in our package.json file ( including Express )

 

Oh, I miss this step in your tutorial .
It's all good then, thx for the reply !

 
 
 

that's what I was aiming for :) Glad you like it :)

 

maybe it will help mentioning that after changing your app or docker file, the image has to be rebuilt.

 

thank you for that Lucian. I'll add it :)

 

hello, I get this error when trying to run it from my virtual machine, please advise :

silviu@ubuntu:~/dockerProject/nodeStuff$ docker build -t chrisnoring/node:latest .
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=ektidoagm9w9a8q0qwcmzjq9h&shmsize=0&t=chrisnoring%2Fnode%3Alatest&target=&ulimits=null&version=1: dial unix /var/run/docker.sock: connect: permission denied

 
 

Thank you Chris, the fix from there worked. The problem was that my user did not had permission to access the /var/run/docker.sock.

code of conduct - report abuse