【问题标题】:Why the docker-compose.yml file is not working on Windows 10? But the same file can work on Mac为什么 docker-compose.yml 文件在 Windows 10 上不起作用?但是相同的文件可以在 Mac 上运行
【发布时间】:2019-06-05 03:22:43
【问题描述】:
  • docker 版本 (MacOS)
Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:39 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     false
  • docker 版本(Win 10)
Client:
 Version:           18.03.0-ce
 API version:       go1.9.4
 git commit:             Sun Feb 10 04:12:39 2019
 OS/Arch:           falsews/amd64
 Orchestrator:      swarm

Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      go1.10.8inimum version 1.12)
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          false/amd64
  Experimental:     
  • docker-compose.yml
version: "3"

services:

    web:
        image: acc:v1
        container_name: web
        # privileged: true
        ports:
            - "9090:8000"
        links:
            - db
        depends_on:
            - db
        volumes:
            - ./code/:/usr/src/app/web/
        networks:
            - account
        restart: always
        command: bash -c "tail -f /dev/null"

    db:
        image: db:v1
        # privileged: true
        ports:
            - "9906:3306"
        container_name: db
        environment:
            - MYSQL_ROOT_PASSWORD=my
        restart: unless-stopped
        networks:
            - account

    nginx:
        image: nn:v1.1
        # privileged: true
        ports:
            - "8082:80"
            - "8083:8080"
        container_name: nginx
        restart: unless-stopped
        depends_on:
            - web
        links:
            - web
        volumes:
            - ./nginx/:/root/html/
        networks:
            - account

networks:
    account:
        driver: bridge

  • MacOS 没问题。
$ docker-compose up -d
  • Win 10 不是。
    1. 第一步
$ docker-compose up -d
error: can't create..: No command specified. 
  1. 第二步 ==> 在 .yml 文件中添加命令
...
        networks:
            - account
        command: /bin/bash
...
error: OCI runtime create failed:..(345):starting container process caused "exec : /bin/bash":stat /bin/bash: No such file or directory: unknow.
  1. 第三步 ==> 更改命令
    • 我试过 sh | /bin/bash | /bin/sh | ls | /bin/ls |等等。

这太奇怪了。 我想在 Windows 10 上使用 docker-compose.yml 文件运行容器。

【问题讨论】:

    标签: docker docker-compose dockerfile


    【解决方案1】:

    我不禁要问你是否有 Ubuntu 或 Linux bash 环境来在 Windows 中运行 bash 命令。

    http://techgenix.com/bash-on-windows-10/ 您需要让它能够运行此命令: in your Docker-compose.yml command: bash -c "tail -f /dev/null"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多