Skip to content
Advertisement

Windows compatibility: Permissions?

OS Windows 10, I am using Docker Engine version 18.09.2, the API version is 1.39

The website explaining the steps to run CAT is: https://libraries.io/pypi/medcat

I am building the medcat image locally. Output looks good until the end of the build process:

    Step 10/11 : ENTRYPOINT ["python"]
     ---> Using cache
     ---> 66b414e2093d
    Step 11/11 : CMD ["api.py"]
     ---> Using cache
     ---> db2acf6c4649
    Successfully built db2acf6c4649
    Successfully tagged cat:latest
    SECURITY WARNING: You are building a Docker image from Windows against 
    a non-Windows Docker host. All files and directories added to build 
    context will have '-rwxr-xr-x' permissions. It is recommended to 
    double check and reset permissions for sensitive files and 
    directories.

When I am trying to start the container I just built, I get:

    IT IS UMLS
     * Serving Flask app "api" (lazy loading)
     * Environment: production
       WARNING: This is a development server. Do not use it in a 
    production deployment.
       Use a production WSGI server instead.
     * Debug mode: on
    Traceback (most recent call last):
      File "api.py", line 66, in <module>
        app.run(debug=True, host='0.0.0.0', port=5000)
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 
    944, in run 
    run_simple(host, port, self, **options)
      File "/usr/local/lib/python3.7/site-packages/werkzeug/serving.py", 
    line 1007, in run_simple
        run_with_reloader(inner, extra_files, reloader_interval, 
    reloader_type)
      File "/usr/local/lib/python3.7/site-packages/werkzeug/_reloader.py", 
    line 332, in run_with_reloader
        sys.exit(reloader.restart_with_reloader())
      File "/usr/local/lib/python3.7/site-packages/werkzeug/_reloader.py", 
    line 176, in restart_with_reloader
        exit_code = subprocess.call(args, env=new_environ, 
    close_fds=False)
      File "/usr/local/lib/python3.7/subprocess.py", line 323, in call
        with Popen(*popenargs, **kwargs) as p:
      File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__
        restore_signals, start_new_session)
      File "/usr/local/lib/python3.7/subprocess.py", line 1522, in 
    _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    OSError: [Errno 8] Exec format error: '/cat/api/api.py'

Does anyone have experience with building on Windows? Does the security warning have anything to do with this?

Update: I added the permission for linux executable as in the received answer at this post. Then I built the image locally using the following command docker build --network=host -t cat -f Dockerfile.MedMen ., and the end of the building process gives me the same Security Warning. Then I checked docker run --env-file=./envs/env_medann ubuntu:18.04 env, which gave me:

    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    HOSTNAME=3d5fd66fadbe
    TYPE=UMLS
    DEBUG=False
    CNTX_SPAN=6
    CNTX_SPAN_SHORT=2
    MIN_CUI_COUNT=100
    MIN_CUI_COUNT_STRICT=1
    MIN_ACC=0.01
    MIN_CONCEPT_LENGTH=1
    NEG_PROB=0.2
    LBL_STYLE=def
    SPACY_MODEL=en_core_sci_md
    UMLS_MODEL=/cat/models/med_ann_norm.dat
    VOCAB_MODEL=/cat/models/med_ann_norm_dict.dat
    MKL_NUM_THREAD=1
    NUMEXPR_NUM_THREADS=1
    OMP_NUM_THREADS=1
    HOME=/root

Advertisement

Answer

This is because windows & linux has CR-LF & LF difference issue, meanwhile, permission need to be added for linux executable.
For your case, as you have got the source code, I think you have git installed on your windows. Then, you can open Git Bash, change the path to your source code directory, and execute next in it:

find . -type f | xargs dos2unix
chmod -R 777 *

Finally, rebuild it.


Update:

I try your code completely, it seems the issue is in cat/api/api.py, it misses a #!. So, into your sourcecode, edit cat/api/api.py, add next at the beginning of the sourcecode:

#!/usr/bin/env python

Then, rebuild with Dockerfile & run it again, you can see the effect from browser:

enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement