admin管理员组

文章数量:1403366

I'm trying to set up a GitHub Actions workflow to run tests inside a Docker container. The workflow fails when I attempt to mount a volume from the repository into the Docker container.

  • I have a project in a GitHub repository.
  • In the GitHub Actions workflow, I am creating a coverage directory inside the Quality Control folder.
  • I am using Docker to run tests and generate the coverage report, and I'm trying to mount the coverage directory into the container.

However, when running the container, I get the following error:

Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /home/runner/work/WebUi/WebUi/QualityControl/coverage

Workflow YAML:

jobs:
  coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Create Coverage Directory
        run: mkdir -p QualityControl/coverage && ls -ld QualityControl/coverage
      - uses: actions/checkout@v4
      - run: (cd QualityControl; npm ci)
      - run: (cd QualityControl; npm run docker-coverage)

Docker compose configuration:

services:
  test_app:
    build:
      target: coverage
    command: ["/opt/wait-for-it.sh", "-t", "0", "test_db:3306", "--", "npm", "run", "coverage-lcov"]
    volumes:
      - type: bind
        source: ./coverage
        target: /usr/src/app/coverage
        read_only: false

What I’ve Tried:

  • I’ve confirmed that the coverage directory exists with mkdir -p and ls.
  • I've tried using both absolute and relative paths in docker-compose.yml.
  • I’ve ensured the docker-compose command runs within the QualityControl folder.

Despite this, I keep encountering the error that Docker can't find the source path for the volume. Question:

How can I fix the issue where Docker is unable to mount the coverage directory in GitHub Actions? Why is Docker not recognizing the directory even though it is created before the container starts?

I'm trying to set up a GitHub Actions workflow to run tests inside a Docker container. The workflow fails when I attempt to mount a volume from the repository into the Docker container.

  • I have a project in a GitHub repository.
  • In the GitHub Actions workflow, I am creating a coverage directory inside the Quality Control folder.
  • I am using Docker to run tests and generate the coverage report, and I'm trying to mount the coverage directory into the container.

However, when running the container, I get the following error:

Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /home/runner/work/WebUi/WebUi/QualityControl/coverage

Workflow YAML:

jobs:
  coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Create Coverage Directory
        run: mkdir -p QualityControl/coverage && ls -ld QualityControl/coverage
      - uses: actions/checkout@v4
      - run: (cd QualityControl; npm ci)
      - run: (cd QualityControl; npm run docker-coverage)

Docker compose configuration:

services:
  test_app:
    build:
      target: coverage
    command: ["/opt/wait-for-it.sh", "-t", "0", "test_db:3306", "--", "npm", "run", "coverage-lcov"]
    volumes:
      - type: bind
        source: ./coverage
        target: /usr/src/app/coverage
        read_only: false

What I’ve Tried:

  • I’ve confirmed that the coverage directory exists with mkdir -p and ls.
  • I've tried using both absolute and relative paths in docker-compose.yml.
  • I’ve ensured the docker-compose command runs within the QualityControl folder.

Despite this, I keep encountering the error that Docker can't find the source path for the volume. Question:

How can I fix the issue where Docker is unable to mount the coverage directory in GitHub Actions? Why is Docker not recognizing the directory even though it is created before the container starts?

Share Improve this question asked Mar 21 at 8:46 Alejandro Mariscal RomeroAlejandro Mariscal Romero 113 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Paths can be case sensitive in the workflow yaml you have:

mkdir -p QualityControl/coverage && ls -ld QualityControl/coverage

In the docker compose you have:

target: /usr/src/app/coverage

Whilst this is the target not the source this makes me wonder if you have when specifying the full path varied the case?

本文标签: Error mounting volume in Docker with GitHub Actions 39bind source path does not exist39Stack Overflow