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 😊😊


If anyone gets a syntax error in their IDE in the app.js code that says "'import' is only available in ES6 (use 'esversion: 6')," follow these instructions:


Yet another note: the tutorial doesn't include instructions on how to stop running your container. There has to be a better way than this, but I had to open a new Terminal tab, find the ID of my container by running

docker container ls

. I copied and pasted the id and then ran

docker container stop [ID]


actually, you can run docker ps to get a list of running containers. Then you can find out both name and id, either is good when you try to stop it next which you do with docker stop [id or name]. Usually, you only need the first 2-3 characters of the id


Realized this is addressed later in the tutorial, yay :)


When you run

docker build -t [YOUR STUFF]

NOTE: the -t flag stands for 'tag.' According to the Docker documentation:
--tag , -t: Name and optionally a tag in the ‘name:tag’ format


The Docker exec command has to be done on a RUNNING container


fair point Andy. I've updated the text, thanks :)


Another note: when you get to the step where you build your first image, the command would be more accurately described as:



well the tagging is pretty much up to you it could be chris/node-web-app. You are right though that you need to name it in a specific way when you tag it for the container registry for Azure for example for your container registry to accept it. I'm sure that's true for AWS as well


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:


Without using curly brackets, the port wasn't available inside the Nodejs file. Do you know why? I'm using Docker (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?

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 <-- use this ip address


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.


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


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 )


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


Thanks for the tutorial. But it would help to mention that to exit the interactive bash, you'd type ctrl+d to exit.


appreciate that comment Okolie, I will update per your suggestion :)


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