試圖用boot2docker在我的mac os x上運行docker。在mac os x上運行docker with boot2docker?
一切似乎都很好,但我無法運行碼頭圖像。我必須失去一些明顯的東西。
指南我用:
NodeJs Web App
Docker on Mac OS X
我的搬運工文件:
FROM ubuntu:12.04
# Build dependencies
RUN apt-get -y update
RUN apt-get install build-essential -y
RUN apt-get install curl -y
# Install NodeJS
RUN curl -L http://nodejs.org/dist/v0.10.22/node-v0.10.22.tar.gz | tar -xz
RUN cd /node-v0.10.22 && ./configure
RUN cd /node-v0.10.22 && make && make install && make clean
# Global NPM installs
RUN npm install --silent -g express lodash ejs forever
RUN mkdir /app
ADD server.js /app/server.js
ADD dist /app/dist
ADD lib /app/lib
Add test.js /app/test.js
CMD ["node", "/app/test.js"]
EXPOSE 8080
碼頭工人建立輸出:test.js的
@xp (master) ~/work/front-portal: docker build -t front-portal .
Uploading context 118.7 MB
Uploading context
Step 0 : FROM ubuntu:12.04
---> 9cd978db300e
Step 1 : RUN apt-get -y update
---> Using cache
---> ee9a4b864ffb
Step 2 : RUN apt-get install build-essential -y
---> Using cache
---> e7dd304d6f92
Step 3 : RUN apt-get install curl -y
---> Using cache
---> ded30df6d5c2
Step 4 : RUN curl -L http://nodejs.org/dist/v0.10.22/node-v0.10.22.tar.gz | tar -xz
---> Using cache
---> d132c9cdd09c
Step 5 : RUN cd /node-v0.10.22 && ./configure
---> Using cache
---> 9036f0ce77d2
Step 6 : RUN cd /node-v0.10.22 && make && make install && make clean
---> Using cache
---> c29bcfa1d058
Step 7 : RUN npm install --silent -g express lodash ejs forever
---> Using cache
---> d389052f5e49
Step 8 : RUN mkdir /app
---> Using cache
---> 33576951eb9b
Step 9 : ADD server.js /app/server.js
---> Using cache
---> 2a4aa2230170
Step 10 : ADD dist /app/dist
---> Using cache
---> 4350b786481c
Step 11 : ADD lib /app/lib
---> Using cache
---> 58b0a3850c01
Step 12 : Add test.js /app/test.js
---> Using cache
---> 441d63b47297
Step 13 : CMD ["node", "/app/test.js"]
---> Using cache
---> 013aaa78b0a5
Step 14 : EXPOSE 8080
---> Running in 8962747dd91a
---> 7410cc1bdbed
Successfully built 7410cc1bdbed
內容:
var express = require('express');
// Constants
var PORT = 8080;
// App
var app = express();
app.get('/', function (req, res) {
res.send('Hello World\n');
});
app.listen(PORT)
console.log('Running on http://localhost:' + PORT);
Boot2docker運行:
[email protected] (master) ~/work/front-portal: DEBUG=1 docker run front-portal
[debug] commands.go:2484 [hijack] End of stdout
[debug] commands.go:2079 End of CmdRun(), Waiting for hijack to finish.
[email protected] (master) ~/work/front-portal:
雖然簡單回聲工作:
[email protected] (master) ~/work/front-portal: DEBUG=1 docker run front-portal echo "test"
test
[debug] commands.go:2484 [hijack] End of stdout
[debug] commands.go:2079 End of CmdRun(), Waiting for hijack to finish.
[email protected] (master) ~/work/front-portal:
我的節點test.js文件
[email protected] (master) ~/work/front-portal: ./boot2docker status
[2014-02-12 18:32:50] boot2docker-vm is running.
[email protected] (master) ~/work/front-portal:
但我無法啓動泊塢窗是好的:
[email protected] (master) ~/work/front-portal: node test.js
Running on http://localhost:8080
[email protected] (master) ~/work/front-portal: DEBUG=1 docker run front-portal ls -al /app/test.js
-rw-r--r-- 1 501 dialout 232 Feb 12 2014 /app/test.js
[debug] commands.go:2484 [hijack] End of stdout
[debug] commands.go:2079 End of CmdRun(), Waiting for hijack to finish.
[email protected] (master) ~/work/front-portal: