Ich stelle eine einfache node.js-App auf der Docker-Plattform eines digitalen Ozean-Servers bereit.kann npm nicht im Docker-Container installieren?
// package.json
{
"name": "docker-centos-hello",
"private": true,
"version": "0.0.1",
"description": "Node.js Hello world app on CentOS using docker",
"author": "Daniel Gasienica <[email protected]>",
"dependencies": {
"express": "3.2.4"
}
}
// app.js
var express = require('express');
var PORT = 3000;
var app = express();
app.get('/', function (req, res) {
res.send('Hello world\n');
});
app.listen(PORT);
console.log('Running on http://localhost:' + PORT);
// Andockfensters Datei
FROM dockerfile/nodejs
# Set the working directory
WORKDIR /src
EXPOSE 3000
CMD ["/bin/bash"]
Die Andockfensters Basisbild ist das dockerfile/NodeJS, die Ich habe ein node.js gebaut, ich habe das Bild erstellt:
docker build -t test1 /home/sizhe/docker/test
und das Bild laufen:
docker run -it -p 8080:3000 -v /home/sizhe/docker/test1:/src test
Durch das Bild läuft, kann ich erfolgreich in den Behälter werden die App alle Dateien in den Container kopiert. wenn ich den Befehl versucht, die node.js Abhängigkeit zu installieren:
npm install
jedoch npm nicht alle Pakete herunterladen, mit einem Fehler:
Linux 3.13.0-40-generic
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.10.35
npm ERR! npm v2.1.16
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! network getaddrinfo ENOTFOUND
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
Danke! Neustart docker ('boot2docker restart') funktionierte für mich. – Leons
Angepasst für Docker Machine @Leons Vorschlag funktionierte für mich: 'docker-machine restart' –
marcusstenbeck
Danke, ich werde die Antwort aktualisieren –