2

On my Windows 10 Home computer with Docker Toolbox, Docker is having trouble mounting the drives. I've already run dos2unix on the entrypoint.sh file.

The full error is as such:

ERROR: for users  Cannot start service users: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"/usr/src/app/entrypoint.sh\": stat /usr/src/app/entrypoint.sh: no such file or directory": unknown

My docker-compose.yml:

version: '3.7'

services:

  users:
    build:
      context: ./services/users
      dockerfile: Dockerfile
    entrypoint: ['/usr/src/app/entrypoint.sh']
    volumes:
      - './services/users:/usr/src/app'
    ports:
      - 5001:5000
    environment:
      - FLASK_ENV=development
      - APP_SETTINGS=project.config.DevelopmentConfig
      - DATABASE_URL=postgresql://postgres:postgres@users-db:5432/users_dev
      - DATABASE_TEST_URL=postgresql://postgres:postgres@users-db:5432/users_test
    depends_on:
      - users-db

Curiously, when I comment out the "volumes" section, it works! But I want to be able to mount volumes in the future.

Directory structure can be seen as such:

D:\flask-react-auth
│   .gitignore
│   .gitlab-ci.yml
│   docker-compose.yml
│   README.md
│   release.sh
│   
└───services
    │   
    └───users
        │   .coveragerc
        │   .dockerignore
        │   Dockerfile
        │   Dockerfile.prod
        │   entrypoint.sh
        │   manage.py
        │   requirements-dev.txt
        │   requirements.txt
        │   setup.cfg
        │   tree.txt
        │   
        └───project
            │   config.py
            │   __init__.py
            │   
            ├───api
            │   │   ping.py
            │   │   __init__.py
            │   │   
            │   └───users
            │           admin.py
            │           crud.py
            │           models.py
            │           views.py
            │           __init__.py
            │           
            ├───db
            │       create.sql
            │       Dockerfile
            │       
            └───tests
                    conftest.py
                    pytest.ini
                    test_admin.py
                    test_config.py
                    test_ping.py
                    test_users.py
                    test_users_unit.py
                    __init__.py

I have added the D:\flask-react-auth\ to the 'Shared Folders' on virtualbox as well.

ameyades
  • 43
  • 1
  • 8
  • Does the `entrypoint.sh` script have DOS or Unix line endings? Does it name an interpreter that doesn't exist (Alpine-based images will have a `/bin/sh` but not GNU Bash, for example)? – David Maze May 05 '20 at 01:56
  • I ran dos2unix on entrypoint.sh, so that should be taken care of. It is using alpine linux. The crazy thing is that it's able to `RUN chmod +x /usr/src/app/entrypoint.sh` from the dockerfile! This error happens for some mysterious reason **after** the dockerfile has finished running – ameyades May 05 '20 at 02:06
  • It doesn't matter what you've done to files from the Dockerfile when you mount a volume over top of them. Dockerfile makes the image, and volume applies to the container (build vs run). – BMitch Jul 29 '20 at 22:06

1 Answers1

1

The answer seems obvious to me:

When you run the code as is * it mounts the current working directory to '/usr/src/app'. * The current working directory does not have a file 'entrypoint.sh'. * It tries to run '/usr/src/app/entrypoint.sh' but it is not there so it fails.

When you comment out that volume mount * I assume the image already has '/usr/src/app/entrypoint.sh' so it just works.

I think you probably should change the mounting code from

    volumes:
      - '.:/usr/src/app'

to

    volumes:
      - './services/users:/usr/src/app'
emory
  • 10,725
  • 2
  • 30
  • 58
  • What if you changed `entrypoint: ['/usr/src/app/entrypoint.sh']` to `entrypoint: ['sh', '/usr/src/app/entrypoint.sh']`. If that does not work can you change it temporarily to `entrypoint: ['ls', '/usr/src/app']` `entrypoint: ['stat', '/usr/src/app/entrypoint.sh']` to see what that output that gives you. – emory May 06 '20 at 13:10