鍍金池/ 問答/Java  Linux/ 使用 docker-compose 啟動(dòng)報(bào)錯(cuò):No such file or d

使用 docker-compose 啟動(dòng)報(bào)錯(cuò):No such file or directory 如何解決?

使用 docker-compose 方式啟動(dòng)容器,提示 No such file or directory,我懷疑是不是這里錯(cuò)了,docker-compose.yml 如下:

version: "3.1"

services:
  php:
    image: php:7.1.7-cli
    volumes:
      - .:/opt/php
    privileged: true
    command: ["/opt/php/docker/test_runner.sh"]

這里 volumes 想表達(dá)的是當(dāng)前目錄跟鏡像中的 /opt/php 目錄做共享,但是 windows 下可能不是這樣寫,試了 ./ 也不行,求解!

具體報(bào)錯(cuò)如下:

PS C:\Users\tanteng\website\DesignPatternsPHP> docker-compose up
Starting designpatternsphp_php_1 ...
Starting designpatternsphp_php_1 ... done
Attaching to designpatternsphp_php_1
: No such file or directory
designpatternsphp_php_1 exited with code 127
回答
編輯回答
替身

Windows或者Linux下,我一般都是直接寫的絕對路徑
同時(shí)也建議寫成完整路徑,這些看起來更加清晰易懂

volumes:
  - H:/code:/webser/www  # H是盤符,H:/code是Windows共享目錄
2017年5月12日 02:26
編輯回答
凹凸曼

給你看看我的 nginx 配置:

services:
    nginx:
        image: "nginx:alpine"
        container_name: oxf-nginx
        restart: on-failure
        ports:
            - "80:80"
        volumes:
            - ./data/conf/nginx.conf:/etc/nginx/nginx.conf
            - ./data/html/:/usr/share/nginx/html
            - ./data/log/:/var/log/nginx
        environment:
            - NGINX_PORT=80
        command: nginx -g 'daemon off;'

目錄樹如下:

.
├── data
│?? ├── conf
│?? │?? └── nginx.conf
│?? ├── html
│?? │?? ├── index.html
│?? │?? ├── test
│?? │?? │?? ├── index.html
│?? │?? │?? ├── test.htm
│?? │?? │?? └── test.html
│?? │?? └── test.htm
│?? └── log
│??     ├── access.log
│??     └── error.log
└── docker-compose.yaml
2018年5月31日 23:38