我正在使用 docker-compose 并且我想创建一个相对的双路径绑定。
Folder structure and path at the host machine:
/Users/username/Documents/Repos/docker-gulp-template/bla
docker-gulp-template
Dockerfile
docker-compose.yml
Bla (Folder)
Run Code Online (Sandbox Code Playgroud)
Path structure inside the container:
/usr/src/html/bla
Run Code Online (Sandbox Code Playgroud)
version: '3'
services:
bla:
command: /bin/bash
stdin_open: true
#tty: true
container_name: docker-gulp-template
#restart: always
build: .
ports:
- '80:3000'
volumes:
- "/bla:/usr/src/html/bla"
Run Code Online (Sandbox Code Playgroud)
这确实会导致错误。
ERROR: for docker-gulp-template Cannot start service bla: b'Mounts denied: \r\nThe path /bla\r\nis not shared from OS X and is not known to Docker.\r\nYou can configure shared paths from Docker -> Preferences... -> File Sharing.\r\nSee …Run Code Online (Sandbox Code Playgroud) 目前我尝试启动 Node.js 服务器,并且我确实想了解 server.listen 的参数。
server.listen(port, hostname, backlog, callback);
Run Code Online (Sandbox Code Playgroud)
问题:据我了解,listen 的 2. 参数应该是主机名。结果应该是,我能够通过“主机名:7000”到达服务器,但结果是脚本崩溃了。没有“主机名”一切正常。这里有什么问题吗?“主机名”有什么用?
const server = http.createServer(function (req, res) {
console.log(req);
});
server.listen(7000, "bla");
Run Code Online (Sandbox Code Playgroud)
浏览器:
bla:7000
Run Code Online (Sandbox Code Playgroud)
不起作用。
错误:
Error: listen EADDRNOTAVAIL 22.0.0.0:7000
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at Server._listen2 (net.js:1246:19)
at listen (net.js:1295:10)
at net.js:1405:9
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
Run Code Online (Sandbox Code Playgroud)