FG
💻 Software☁️ Cloud & DevOpsDocker

Not mounting host volumes on `docker-compose up`

Fresh5 days ago
Mar 14, 20260 views
Confidence Score58%
58%

Problem

We have an machine that's having an issue where host volumes aren't being mounted inside of the container on `docker-compose up`. We're running Arch x86_64 with Linux 4.2.3, Docker version 1.8.3, build f4bf5c7-dirty, and docker-compose version: 1.4.2. Here's our config: docker-compose.yml [code block] While `wsgi` service works just fine (which uses the same `./app` directory), the `dev` service doesn't. Even stranger, it seems that we're able to get host volumes mounted inside the container just fine with a shell command that does the same thing. [code block] Weird, right? Here are our logs, showing that the file `./app/util/start` isn't being mounted to `/mnt/app/util/start`, whereas it's definitely there when we build the directory (as opposed to mounting a host volume). [code block] And the results of `lxc-checkconfig`:

Error Output

error
Stopping locationmanagement_web_1... done

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix Host Volume Mounting Issues in Docker Compose

Medium Risk

The issue is likely due to the version of Docker and Docker Compose being used, which may have bugs or limitations related to volume mounting. Additionally, the configuration in the `docker-compose.yml` file may not be correctly set up for the `dev` service, leading to the host volumes not being mounted as expected.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Update Docker and Docker Compose

    Upgrade Docker and Docker Compose to the latest stable versions to ensure compatibility and bug fixes related to volume mounting.

    bash
    sudo pacman -Syu docker docker-compose
  2. 2

    Check docker-compose.yml Configuration

    Verify that the volume configuration for the `dev` service in the `docker-compose.yml` file is correctly defined. Ensure that the syntax is correct and that the paths are accurate.

    yaml
    volumes:
      - ./app:/mnt/app
  3. 3

    Inspect Docker Daemon Logs

    Check the Docker daemon logs for any error messages or warnings related to volume mounting. This can provide insight into what might be going wrong.

    bash
    sudo journalctl -u docker.service
  4. 4

    Test Volume Mounting with Docker CLI

    Run a simple Docker command to test if the volume mounts correctly outside of Docker Compose. This will help identify if the issue is specific to Docker Compose or a broader Docker problem.

    bash
    docker run -v $(pwd)/app:/mnt/app alpine ls /mnt/app
  5. 5

    Rebuild Docker Compose Services

    After making changes, rebuild the Docker Compose services to ensure that the configuration is applied. Use the `--force-recreate` flag to ensure all containers are recreated.

    bash
    docker-compose up --force-recreate

Validation

Confirm that the host volumes are now correctly mounted inside the `dev` service container by checking the contents of `/mnt/app` after running `docker-compose up`. You should see the files from the `./app` directory reflected inside the container.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

dockerdocker-composecontainers