Skip to content

Problem with exercise 1.9 when using WSL2 #122

@anttijman

Description

@anttijman

I faced a problem in exercise 1.9 when using WSL2.

When using -v to bind mount a file, and the file does not exist on host machine, a directory is created by default. The file has to be created before executing the command
docker -run -v "$(pwd)/text.log:/usr/src/app/text.log" devopsdockeruh/simple-web-service

So, the problem is that even if you remove the directory text.log from host machine after first time, and then create the file text.log on host machine, and then rerun the same command it outputs an error message: docker: Error response from daemon: not a directory.
I overcame the problem with bind mounting the file with a different name.

Steps to reproduce:

  1. Use WSL2 ubuntu
  2. Make sure you do not have a file named text.log in your working directory
  3. Run
    docker run -v "$(pwd)/text.log:/usr/src/app/text.log" devopsdockeruh/simple-web-service
  4. Creates a directory named text.log in your host machine working directory
  5. Remove the directory text.log from your working directory
    rm -r text.log
  6. Create a file text.log
    touch text.log
  7. Rerun command from step two
  8. Outputs an error
    docker: Error response from daemon: not a directory

See: docker/for-win#9823

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions