Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Error running Flask entrypoint #25
I have cloned this repo and tried a few different branch, test3~test6. It all have this issue that I can't seem to fixed. I've tried to change it into
I am currently following PART 1 of the course; more specifically, I am getting the users-service to work (https://testdriven.io/part-one-docker-config). However, the preceding error is not the first I have come across. After initially creating the docker-compose-dev.yml and Dockerfile (copied verbatim), I proceeded to build and run the container--in the foreground to monitor any errors:
Unfortunately, the build failed and returned with an error stating that
aside: Could this be a issue with docker-machine? Is it possible that docker-machine isn't correctly mapping the current project dir into the vm? See cookiecutter-django issue #895
[SOLVED]: Turns out the files in my local user-service directory weren't copied over into the remote machine. To fix the
The solution was found here: docker/machine#1577
Note that I first had to copy the files to /tmp on the remote machine; the reason: failed permissions.
@bin4ryio So, I added sudo and it did in fact start the new, containerized flask app( I was able to request the json data returned from
After a little analysis, I noticed that the application files inside the image were being replaced by the volume files created in the docker-compose-dev.yml file:
When this occurs we get the error while executing the container:
By removing the volume from the compose file, the above error no longer occurred. However, the application still did not work.
Looking a bit more, I noticed that I was using the flask client implementation, according to the article. The command inside the entrypoint.sh should then change from
I also added execute permission to the entrypoint.sh file, both in the image build and in the container initialization and simplified the Dockerfile-dev file, as follows:
Or alternatively you can change the path of entrypoint.sh file:
After these adjustments the container has been up and running normally. ;)
PS: I'm using docker on mac os. Running the container on ubuntu server did not identify this problem. Maybe it's something related to docker machine or file permissions on mac.
@vinnyA3, Until this step, I still can not update the changes in my local code automatically into the container. And yes, volume is necessary for this. I'll look a bit more to understand why the code is not yet automatically updated and will return you.
PS: I'm using docker on mac os.
I'm having the exact same problem. Just formatted my computer and can't make it work.
Docker-machine version 0.15.0
Docker version 18.05.0 ce build f150324
Windows 10 with Hyper-V enabled
This is the content of my docker-compose-dev.yml
version: '3.3' services: users: container_name: users build: context: ./services/users dockerfile: Dockerfile-dev volumes: - './services/users:/usr/src/app' ports: - 5001:5000 environment: - FLASK_APP=project/__init__.py - FLASK_DEBUG=1
FROM python:3.7 # set working dir RUN mkdir -p /usr/src/app WORKDIR /usr/src/app # install requirements COPY . /usr/src/app RUN pip install -r requirements.txt # run server CMD ["./entrypoint.sh"]
#!/usr/bin/env sh python manage.py run -h 0.0.0.0
And the error:
$ docker-compose -f docker-compose-dev.yml up --build Removing users Building users Step 1/6 : FROM python:3.7 ---> ce54ff8f2af6 Step 2/6 : RUN mkdir -p /usr/src/app ---> Using cache ---> baad3d95943d Step 3/6 : WORKDIR /usr/src/app ---> Using cache ---> 785cf8a98066 Step 4/6 : COPY . /usr/src/app ---> Using cache ---> 133bf8be6979 Step 5/6 : RUN pip install -r requirements.txt ---> Using cache ---> ec0837430a00 Step 6/6 : CMD ["./entrypoint.sh"] ---> Using cache ---> 93ef097d103e Successfully built 93ef097d103e Successfully tagged testdriven_users:latest Recreating 00242808eea8_users ... error ERROR: for 00242808eea8_users Cannot start service users: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./entrypoint.sh\": stat ./entrypoint.sh: no such file or directory": unknown ERROR: for users Cannot start service users: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./entrypoint.sh\": stat ./entrypoint.sh: no such file or directory": unknown ERROR: Encountered errors while bringing up the project.
It seems to be a problem with the volumes option of docker-compose-dev.yml file.
The solution provided by @bal699 did not work.
@mjhea0 , thank you for your suggestion but it did not work running without docker-machine. The server did start, but the host would become unaccessible (connection refused).
After running several scenarios, I finally got it working.
These are the ones I remember trying:
It happens that the latest Docker for Windows is not working as it should. Docker Machine won't work with Hyper-V and it won't boot up if I disable Hyper-V and install Virtualbox so the solution was to downgrade to Docker Toolbox for Windows, to be able to use Virtualbox properly.
Here are my results:
bruno@DESKTOP-RL0SAF0 MINGW64 /e/Cursos/testdriven $ docker-machine create -d virtualbox testdriven-dev Running pre-create checks... Creating machine... (testdriven-dev) Copying C:\Users\bruno\.docker\machine\cache\boot2docker.iso to C:\Users\bruno\.docker\machine\machines\testdriven-dev\boot2docker.iso... (testdriven-dev) Creating VirtualBox VM... (testdriven-dev) Creating SSH key... (testdriven-dev) Starting the VM... (testdriven-dev) Check network to re-create if needed... (testdriven-dev) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar. (testdriven-dev) Waiting for an IP... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with boot2docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: C:\Program Files\Docker Toolbox\docker-machine.exe env testdriven-dev bruno@DESKTOP-RL0SAF0 MINGW64 /e/Cursos/testdriven $ docker-machine restart testdriven-dev Restarting "testdriven-dev"... (testdriven-dev) Check network to re-create if needed... (testdriven-dev) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar. (testdriven-dev) Waiting for an IP... Waiting for SSH to be available... Detecting the provisioner... Restarted machines may have new IP addresses. You may need to re-run the `docker-machine env` command. bruno@DESKTOP-RL0SAF0 MINGW64 /e/Cursos/testdriven $ docker-machine env testdriven-dev export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.99.102:2376" export DOCKER_CERT_PATH="C:\Users\bruno\.docker\machine\machines\testdriven-dev" export DOCKER_MACHINE_NAME="testdriven-dev" export COMPOSE_CONVERT_WINDOWS_PATHS="true" # Run this command to configure your shell: # eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env testdriven-dev) bruno@DESKTOP-RL0SAF0 MINGW64 /e/Cursos/testdriven $ eval $(docker-machine env testdriven-dev) bruno@DESKTOP-RL0SAF0 MINGW64 /e/Cursos/testdriven $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default - virtualbox Running tcp://192.168.99.100:2376 v18.05.0-ce testdriven-dev * virtualbox Running tcp://192.168.99.102:2376 v18.05.0-ce bruno@DESKTOP-RL0SAF0 MINGW64 /e/Cursos/testdriven $ docker-compose -f docker-compose-dev.yml up --build Creating network "testdriven_default" with the default driver Building users Step 1/8 : FROM python:3.7 3.7: Pulling from library/python 0bd44ff9c2cf: Pull complete 047670ddbd2a: Pull complete ea7d5dc89438: Pull complete ae7ad5906a75: Pull complete 0f2ddfdfc7d1: Pull complete d055f4d7ae62: Pull complete 05152d57a61e: Pull complete 36ebc9dbcca1: Pull complete f62c22fac2b1: Pull complete Digest: sha256:b4833abd1ca2e7bb636e102e58f2bd53382d26d293ecc6241c67fe517d15d0bd Status: Downloaded newer image for python:3.7 ---> 17453243214e Step 2/8 : RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends netcat dos2unix && apt-get -q clean ---> Running in 6ebb8d566c7e debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package netcat-traditional. (Reading database ... 29828 files and directories currently installed.) Preparing to unpack .../netcat-traditional_1.10-41+b1_amd64.deb ... Unpacking netcat-traditional (1.10-41+b1) ... Selecting previously unselected package dos2unix. Preparing to unpack .../dos2unix_7.3.4-3_amd64.deb ... Unpacking dos2unix (7.3.4-3) ... Selecting previously unselected package netcat. Preparing to unpack .../netcat_1.10-41_all.deb ... Unpacking netcat (1.10-41) ... Setting up dos2unix (7.3.4-3) ... Setting up netcat-traditional (1.10-41+b1) ... update-alternatives: using /bin/nc.traditional to provide /bin/nc (nc) in auto mode Setting up netcat (1.10-41) ... Removing intermediate container 6ebb8d566c7e ---> 5b6e3007552c Step 3/8 : RUN mkdir -p /usr/src/app ---> Running in 2c481a57226c Removing intermediate container 2c481a57226c ---> ce3e96c0b844 Step 4/8 : WORKDIR /usr/src/app Removing intermediate container 1c4793bf55e7 ---> dfa6cbb3ac98 Step 5/8 : COPY . /usr/src/app ---> 7860cf8eeb87 Step 6/8 : RUN pip install -r requirements.txt ---> Running in a06fb7a2f9db Collecting click==6.7 (from -r requirements.txt (line 1)) Downloading https://files.pythonhosted.org/packages/34/c1/8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/click-6.7-py2.py3-none-any.whl (71kB) Collecting Flask==1.0.2 (from -r requirements.txt (line 2)) Downloading https://files.pythonhosted.org/packages/7f/e7/08578774ed4536d3242b14dacb4696386634607af824ea997202cd0edb4b/Flask-1.0.2-py2.py3-none-any.whl (91kB) Collecting itsdangerous==0.24 (from -r requirements.txt (line 3)) Downloading https://files.pythonhosted.org/packages/dc/b4/a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4/itsdangerous-0.24.tar.gz (46kB) Collecting Jinja2==2.10 (from -r requirements.txt (line 4)) Downloading https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl (126kB) Collecting MarkupSafe==1.0 (from -r requirements.txt (line 5)) Downloading https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz Collecting Werkzeug==0.14.1 (from -r requirements.txt (line 6)) Downloading https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB) Building wheels for collected packages: itsdangerous, MarkupSafe Running setup.py bdist_wheel for itsdangerous: started Running setup.py bdist_wheel for itsdangerous: finished with status 'done' Stored in directory: /root/.cache/pip/wheels/2c/4a/61/5599631c1554768c6290b08c02c72d7317910374ca602ff1e5 Running setup.py bdist_wheel for MarkupSafe: started Running setup.py bdist_wheel for MarkupSafe: finished with status 'done' Stored in directory: /root/.cache/pip/wheels/33/56/20/ebe49a5c612fffe1c5a632146b16596f9e64676768661e4e46 Successfully built itsdangerous MarkupSafe Installing collected packages: click, Werkzeug, MarkupSafe, Jinja2, itsdangerous, Flask Successfully installed Flask-1.0.2 Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.14.1 click-6.7 itsdangerous-0.24 Removing intermediate container a06fb7a2f9db ---> 371a3c962599 Step 7/8 : RUN dos2unix ./entrypoint.sh ---> Running in 702c40cb977d dos2unix: converting file ./entrypoint.sh to Unix format... Removing intermediate container 702c40cb977d ---> 09a5559ab0b5 Step 8/8 : CMD ["./entrypoint.sh"] ---> Running in 133f437e1a19 Removing intermediate container 133f437e1a19 ---> babbe6505ca2 Successfully built babbe6505ca2 Successfully tagged testdriven_users:latest Creating users ... done Attaching to users users | * Serving Flask app "project/__init__.py" (lazy loading) users | * Environment: production users | WARNING: Do not use the development server in a production environment. users | Use a production WSGI server instead. users | * Debug mode: on users | * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) users | * Restarting with stat users | * Debugger is active! users | * Debugger PIN: 337-063-856 users | 192.168.99.1 - - [07/Jul/2018 04:18:06] "GET /users/ping HTTP/1.1" 200 -
Everything works great now!
I have the exact same issue
$ docker-compose -f docker-compose-dev.yml up -d --build
Successfully built 73ebbe52c8f9
Successfully built 104b7da9289e
ERROR: for 98d92c967447_testdriven-app_users_1 Cannot start service users: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: "/usr/src/app/entrypoint.sh": permission denied": unknown
ERROR: for users Cannot start service users: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: "/usr/src/app/entrypoint.sh": permission denied": unknown
But I manage to work with the solution of @bal699 bal699
$ docker ps
@mjhea0 mjhea0 when will you launch the new version of your course?
@abelthf it was released on July, 16th 2018. Sign up for the mailing list so you don't miss future release announcements. https://testdriven.us17.list-manage.com/subscribe/post?u=bea5ac664532063fe8aa8d6a2&id=eddaf58c2a