I have tried everything I can think of. I have read the docs, blogs and tried following samples on github.
But I can't seem to get it to work.
What I want to do is simple. I want to write my node.js code on my windows 8.1 machine, and I also want to run the code from within a Docker container without having to rebuild the container all the time. So I want to map a directory on my Windows Host to a directory inside the container.
I have created this Dockerfile
FROM node:0.10.38
RUN apt-get update -qq && apt-get install -y build-essential
ENV ZMQ_VERSION 4.1.3
ENV LIBSODIUM_VERSION 1.0.3
RUN curl -SLO "https://download.libsodium.org/libsodium/releases/libsodium-$LIBSODIUM_VERSION.tar.gz" \
&& tar xvf libsodium-$LIBSODIUM_VERSION.tar.gz \
&& cd libsodium-$LIBSODIUM_VERSION \
&& ./configure \
&& make \
&& make install \
&& cd .. \
&& rm -r libsodium-$LIBSODIUM_VERSION \
&& rm libsodium-$LIBSODIUM_VERSION.tar.gz
RUN curl -SLO "http://download.zeromq.org/zeromq-$ZMQ_VERSION.tar.gz" \
&& tar xvf zeromq-$ZMQ_VERSION.tar.gz \
&& cd zeromq-$ZMQ_VERSION \
&& ./configure \
&& make \
&& make install \
&& cd .. \
&& rm -r zeromq-$ZMQ_VERSION \
&& rm zeromq-$ZMQ_VERSION.tar.gz
RUN ldconfig
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
RUN mkdir -p /usr/src/app
ADD . /usr/src/app
WORKDIR /usr/src/app
RUN npm install
EXPOSE 3000
EXPOSE 35729
CMD ["npm", "start"]
I have this simple server.js file
var express = require('express');
var app = express();
var zmq = require('zmq');
app.get('/', function (req, res) {
res.send('ZMQ: ' + zmq.version);
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
And this simple package.json
{
"name": "docker-node-hello-world",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.13.3",
"zmq": "^2.14.0"
}
}
I have installed the latest Docker Toolbox, and can run the Docker Hello World example fine. I try to build my docker image like this when I am in the directory where my Dockerfile is.
docker build -t dockernodetest:dockerfile .
I then try to run it, also from the same location inside the Docker Quickstart Terminal. I use the hash since the tag doesn't take for some reason:
docker run -v //c/Bitbucket/docker-node-hello-world/:/usr/src/app -p 3000:3000 -i -t 9cfd34e046a5 ls ./usr/src/app
The result of this is an empty directory. I was hoping I could just invoke
docker run -v //c/Bitbucket/docker-node-hello-world/:/usr/src/app -p 3000:3000 -i -t 9cfd34e046a5 npm start
But since the host directory isn't available it fails. I have the feeling that I have misunderstood something very basic. I just don't know what.
docker imagescommand?entrypoint.shasENTRYPOINTis defined, arguments will be passed to that script - see ENTRYPOINT