2017-08-15 201 views
1

我正在用無頭瀏覽器構建爬蟲但是現在我想要dockerize我的應用程序我已經在我的泊塢窗圖像中安裝了chrome但是它在運行腳本時會給我一個錯誤。如何在Docker中運行無頭瀏覽器?

StartChrome.js

const chromeLauncher = require('chrome-launcher'); 

chromeLauncher.launch({ 
    port: 9222, 
    chromeFlags: ['--headless','--proxy-server=54.171.181.204:8888','--disable-web-security','--disable-gpu'] 
}).then(chrome => { 
    console.log(`Chrome debugging port running on ${chrome.port}`); 
}); 

ERR

(node:415) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 127.0.0.1:9222 
(node:415) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 

當我在命令行中運行它,它會引發我這樣

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted 
Trace/breakpoint trap 

回答

相關問題