Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid mount config for type "bind": bind source path does not exist #127

Open
Arondight opened this issue Oct 27, 2021 · 17 comments
Open
Labels
question Further information is requested

Comments

@Arondight
Copy link

# docker-compose up -d
[+] Running 26/26
 ⠿ pasteme-mysql Pulled                                                                                                                                                    37.4s
   ⠿ 743f2d6c1f65 Pull complete                                                                                                                                            10.9s
   ⠿ 3f0c413ee255 Pull complete                                                                                                                                            10.9s
   ⠿ aef1ef8f1aac Pull complete                                                                                                                                            11.3s
   ⠿ f9ee573e34cb Pull complete                                                                                                                                            11.4s
   ⠿ 3f237e01f153 Pull complete                                                                                                                                            11.4s
   ⠿ 03da1e065b16 Pull complete                                                                                                                                            25.7s
   ⠿ 04087a801070 Pull complete                                                                                                                                            30.1s
   ⠿ 7efd5395ab31 Pull complete                                                                                                                                            31.3s
   ⠿ 1b5cc03aaac8 Pull complete                                                                                                                                            32.3s
   ⠿ 2b7adaec9998 Pull complete                                                                                                                                            32.8s
   ⠿ 385b8f96a9ba Pull complete                                                                                                                                            33.8s
 ⠿ pasteme-frontend Pulled                                                                                                                                                 23.1s
   ⠿ ddad3d7c1e96 Pull complete                                                                                                                                            11.9s
   ⠿ c7974bc8b744 Pull complete                                                                                                                                            16.1s
   ⠿ d04f0a2e9201 Pull complete                                                                                                                                            16.1s
   ⠿ df7ae1cb4591 Pull complete                                                                                                                                            16.2s
   ⠿ 4259d8811e1d Pull complete                                                                                                                                            16.4s
   ⠿ cad2f7cd9386 Pull complete                                                                                                                                            17.5s
   ⠿ 7645e5aa17f7 Pull complete                                                                                                                                            17.9s
   ⠿ aec638bc861a Pull complete                                                                                                                                            19.1s
   ⠿ 40a6763d6a6f Pull complete                                                                                                                                            19.4s
 ⠿ pasteme-backend Pulled                                                                                                                                                  42.5s
   ⠿ a0d0a0d46f8b Pull complete                                                                                                                                             9.3s
   ⠿ 25078b208636 Pull complete                                                                                                                                            11.3s
   ⠿ 15951c99cd92 Pull complete                                                                                                                                            38.9s
[+] Running 2/2
 ⠿ Network pasteme_default    Created                                                                                                                                       0.2s
 ⠿ Container pasteme-mysql    Created                                                                                                                                       0.4s
 ⠋ Container pasteme-backend  Creating 
Error response from daemon: invalid mount config for type "bind": bind source path does not exist
# rpm -q docker
docker-1.13.1-208.git7d71120.el7_9.x86_64
@Arondight
Copy link
Author

跑一下下面的指令就好了

# mkdir -pv ./data/nginx-logs/ ./data/frontend-usr/

@Arondight
Copy link
Author

我感觉是不是要在文档上注明一下?

@LucienShui LucienShui added the question Further information is requested label Oct 27, 2021
@LucienShui
Copy link
Owner

这是不符合预期的,这两个文件夹按理说应当被自动创建,待我本地测试一下,看能不能复现先。

@Arondight
Copy link
Author

# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

@Arondight
Copy link
Author

不仅仅是我说的那两个目录,所有的目录都需要手动创建。

# mkdir -pv $(grep -oP '(?<=-\h)[^\d]+?(?=:)' ./docker-compose.yml)

@LucienShui
Copy link
Owner

麻烦尝试一下运行 docker run --rm -v "${PWD}/test:/pwd" busybox:latest sh 命令,看下运行完之后,会不会有一个名为 test 的文件夹被创建。

@Arondight
Copy link
Author

[root@nebula-centos-7 PasteMe]# ls
docker-compose.yml
[root@nebula-centos-7 PasteMe]# docker run --rm -v "${PWD}/test:/pwd" busybox:latest sh
Unable to find image 'busybox:latest' locally
Trying to pull repository docker.io/library/busybox ...
latest: Pulling from docker.io/library/busybox
24fb2886d6f6: Pull complete
Digest: sha256:f7ca5a32c10d51aeda3b4d01c61c6061f497893d7f6628b92f822f7117182a57
Status: Downloaded newer image for docker.io/busybox:latest
WARNING: IPv4 forwarding is disabled. Networking will not work.
[root@nebula-centos-7 PasteMe]# tree
.
├── docker-compose.yml
└── test

1 directory, 1 file

@Arondight
Copy link
Author

[root@nebula-centos-7 PasteMe]# ls
docker-compose.yml
[root@nebula-centos-7 PasteMe]# docker run --rm -v "${PWD}/test/1/2/3/:/pwd" busybox:latest sh
WARNING: IPv4 forwarding is disabled. Networking will not work.
[root@nebula-centos-7 PasteMe]# tree
.
├── docker-compose.yml
└── test
    └── 1
        └── 2
            └── 3

4 directories, 1 file

@LucienShui
Copy link
Owner

辛苦再试下这个 docker-compose.yml,看看执行 docker-compose up 之后,有没有 test_dir 被创建。

version: "3"

services:
  busybox:
    image: busybox:latest
    volumes:
      - ./test_dir:/pwd

@Arondight
Copy link
Author

[root@nebula-centos-7 PasteMe]# ls
docker-compose.yml
[root@nebula-centos-7 PasteMe]# cat docker-compose.yml
version: "3"

services:
  busybox:
    image: busybox:latest
    volumes:
      - ./test_dir:/pwd
[root@nebula-centos-7 PasteMe]# docker-compose up
WARN[0000] Found orphan containers ([pasteme-mysql]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
[+] Running 1/0
 ⠿ Container pasteme-busybox-1  Created                                                                                                                                     0.0s
Attaching to pasteme-busybox-1
pasteme-busybox-1 exited with code 0
[root@nebula-centos-7 PasteMe]# tree
.
├── docker-compose.yml
└── test_dir

1 directory, 1 file

@Arondight
Copy link
Author

我顺手在 CentOS 8 上试了一下,一样的问题。

[root@localhost PasteMe]# docker-compose up -d
[+] Running 0/0
 ⠋ Container pasteme-backend  Creating                                                                                                                                      0.0s
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /opt/PasteMe/data/backend-config
[root@localhost PasteMe]# cat /etc/centos-release
CentOS Linux release 8.4.2105
[root@localhost PasteMe]# docker-compose -v
Docker Compose version v2.0.1
[root@localhost PasteMe]# docker -v
Docker version 20.10.8, build 3967b7d

@LucienShui
Copy link
Owner

我去,这就很奇怪了。

因为创建文件夹这一步,是由 docker 来进行的,不受我的管控,如果我刚才提到的两步都没问题的话,按理说,也不应该有这个问题。

@Arondight
Copy link
Author

参考这份文档,我觉得可能是在你的 compose 配置中,docker-compose 认为你用到了 bind-mounts 特性。

If you bind mount a host path into your service’s containers, the path must exist on every swarm node. The Docker swarm mode scheduler can schedule containers on any machine that meets resource availability requirements and satisfies all constraints and placement preferences you specify.

@LucienShui
Copy link
Owner

好的,感谢。超出我所了解的范畴了,我有空研究下。

此外我在本地进行了尝试,是没有问题的。

(python3) root@debian:~/pasteme# uname -a
Linux debian 4.19.0-12-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux
(python3) root@debian:~/pasteme# docker-compose --version
docker-compose version 1.28.2, build unknown
(python3) root@debian:~/pasteme# docker --version
Docker version 19.03.13, build 4484c46d9d
(python3) root@debian:~/pasteme# tree .
.
└── docker-compose.yml

0 directories, 1 file
(python3) root@debian:~/pasteme# cat docker-compose.yml 
version: "3"

services:
  pasteme-frontend:
    image: pasteme/frontend:3.4.2
    container_name: pasteme-frontend
    depends_on:
      - pasteme-backend
    healthcheck:
      test: ["CMD", "curl", "-so", "/dev/null", "localhost:8080/usr/config.json"]
      interval: 45s
      timeout: 3s
      retries: 3
    restart: always
    ports:
      - 80:8080
    volumes:
      - ./data/nginx-logs/:/var/lib/pasteme/
      - ./data/frontend-usr/:/www/pasteme/usr/

  pasteme-backend:
    image: pasteme/go-backend:3.5.2
    container_name: pasteme-backend
    depends_on:
      - pasteme-mysql
    healthcheck:
      test: ["CMD", "wget", "-O", "/dev/null", "localhost:8000/api/v3/?method=beat"]
      interval: 45s
      timeout: 3s
      retries: 3
    restart: always
    volumes:
      - ./data/backend-config/:/etc/pastemed/
    logging:
      driver: "json-file"
      options:
        max-file: "3"
        max-size: "128m"

  pasteme-mysql:
    image: mysql:5.5
    container_name: pasteme-mysql
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      interval: 45s
      timeout: 3s
      retries: 3
    restart: always
    command: [
      '--character-set-server=utf8mb4',
      '--collation-server=utf8mb4_unicode_ci'
    ]
    environment:
      MYSQL_USER: username
      MYSQL_PASSWORD: password
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: pasteme
      MYSQL_MAX_ALLOWED_PACKET: 128M
      MYSQL_INNODB_LOG_FILE_SIZE: 64M
    volumes:
      - ./data/mysql:/var/lib/mysql
    logging:
      driver: "json-file"
      options:
        max-file: "3"
        max-size: "128m"
(python3) root@debian:~/pasteme# docker-compose up -d
Building with native build. Learn about native build in Compose here: https://docs.docker.com/go/compose-native-build/
Creating network "pasteme_default" with the default driver
Creating pasteme-mysql ... done
Creating pasteme-backend ... done
Creating pasteme-frontend ... done
(python3) root@debian:~/pasteme# tree .
.
├── data
│   ├── backend-config
│   │   └── config.json
│   ├── frontend-usr
│   │   ├── config.json
│   │   └── usr.js
│   ├── mysql
│   │   └── ...
│   └── nginx-logs
│       ├── pasteme.error.log
│       └── pasteme.log
└── docker-compose.yml

8 directories, 101 files

@Arondight
Copy link
Author

建议你把 docker-compose 版本拉到最新再试一下。

@LucienShui
Copy link
Owner

你这个问题在你那边可以稳定复现吗?

我把 docker-compose.ymldocker 都更新到了最新版本,看起来是没有问题的。

(python3) root@debian:~/pasteme# uname -a
Linux debian 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux
(python3) root@debian:~/pasteme# docker-compose --version
docker-compose version 1.29.2, build unknown
(python3) root@debian:~/pasteme# docker --version
Docker version 20.10.10, build b485636
(python3) root@debian:~/pasteme# tree .
.
└── docker-compose.yml

0 directories, 1 file
(python3) root@debian:~/pasteme# cat docker-compose.yml
version: "3"

services:
  pasteme-frontend:
    image: pasteme/frontend:3.4.2
    container_name: pasteme-frontend
    depends_on:
      - pasteme-backend
    healthcheck:
      test: ["CMD", "curl", "-so", "/dev/null", "localhost:8080/usr/config.json"]
      interval: 45s
      timeout: 3s
      retries: 3
    restart: always
    ports:
      - 80:8080
    volumes:
      - ./data/nginx-logs/:/var/lib/pasteme/
      - ./data/frontend-usr/:/www/pasteme/usr/

  pasteme-backend:
    image: pasteme/go-backend:3.5.2
    container_name: pasteme-backend
    depends_on:
      - pasteme-mysql
    healthcheck:
      test: ["CMD", "wget", "-O", "/dev/null", "localhost:8000/api/v3/?method=beat"]
      interval: 45s
      timeout: 3s
      retries: 3
    restart: always
    volumes:
      - ./data/backend-config/:/etc/pastemed/
    logging:
      driver: "json-file"
      options:
        max-file: "3"
        max-size: "128m"

  pasteme-mysql:
    image: mysql:5.5
    container_name: pasteme-mysql
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      interval: 45s
      timeout: 3s
      retries: 3
    restart: always
    command: [
      '--character-set-server=utf8mb4',
      '--collation-server=utf8mb4_unicode_ci'
    ]
    environment:
      MYSQL_USER: username
      MYSQL_PASSWORD: password
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: pasteme
      MYSQL_MAX_ALLOWED_PACKET: 128M
      MYSQL_INNODB_LOG_FILE_SIZE: 64M
    volumes:
      - ./data/mysql:/var/lib/mysql
    logging:
      driver: "json-file"
      options:
        max-file: "3"
        max-size: "128m"
(python3) root@debian:~/pasteme# docker-compose up -d
Creating network "pasteme_default" with the default driver
Creating pasteme-mysql ... done
Creating pasteme-backend ... done
Creating pasteme-frontend ... done
(python3) root@debian:~/pasteme# tree .
.
├── data
│   ├── backend-config
│   │   └── config.json
│   ├── frontend-usr
│   │   ├── config.json
│   │   └── usr.js
│   ├── mysql
│   │   └── ...
│   └── nginx-logs
│       ├── pasteme.error.log
│       └── pasteme.log
└── docker-compose.yml

8 directories, 100 files

@Arondight
Copy link
Author

稳定复现

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants