Run Docker Container (with node.js) in Windows 10 (Docker Quick Start Terminal)


Docker scpript:

here

Step 1: Prepare Docker Image With Node.js


$ cd /tmp/


$ curl -L -o Dockerfile https://github.com/nodejs/docker-node/blob/master/7.4/Dockerfile?raw=true


After file has been created or copied:

// next command will create image with instructions from Dockerfile
$ docker build -t image_jessie_node_7_4_0 .


If you will work in windows and receive error:

$ docker build -t <container_name> .
Error checking context: 'can't stat '\\?\C:\Users\UserName\AppData\Local\Application Data''.

Try to do next to solve it:

$ mkdir 1
$ mv Dockerfile ./1
$ cd 1/
$ docker build -t <container_name> .



Docker and Network in Windows

$ docker-machine env default
$ eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default)


$ docker-machine ip
192.168.99.100


$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           v1.11.0


$ docker-machine status default
Running


And with this container you can work by IP 192.168.99.100


Step 3: Create and Run Docker Container

$ project_name=<my_project_name>


$ echo ${project_name}

$ mkdir -p ~/projects/${project_name}


$ cd ~/projects/${project_name}


// For Example:
$ git clone https://github.com/marley-react/The-Complete-React-Web-App-Developer-Course .

and now you can work with this project with any editor.


$ docker run -it \
-p 80:8080 -p 1337:1337 -p 3000:3000 -p 4000:4000 -p 5000:5000 -p 6000:6000 -p 7000:7000 -p 8000:8000 -p 9000:9000 \
--name ${project_name} \
-v ~/projects/${project_name}:/project \
image_jessie_node_7_4_0 \
/bin/bash


# node -v
v7.4.0


# npm -v
4.0.5


# apt-get -qq update

# apt-get install -y vim curl net-tools

net-tools contains ifconfig

create user without additional questions:

# adduser --disabled-password --gecos "" developer

# su - developer
$ cd /project/


And as result, we can work with project on local computer and run project in docker container. In docker container project locate in /project folder.

If you start app, you can connect: http://192.168.99.100:3000/