title: Failed to find attribute 'app' in Docker when image is run
body: <p>I am having a challenge solving an error in Docker. I am building a Flask app and want to deploy it on Docker containers, but when I run my successfully created image using <code>docker run</code>, I get the error <code>Failed to find attribute 'app' in 'gossip_app'</code>.</p>
  <p>Here is the full error message from <code>docker logs</code>:</p>
  <pre class="lang-py prettyprint-override"><code>[2020-10-30 09:54:41,411] INFO in __init__: Tinker ChatApp
  INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
  INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
  INFO  [alembic.runtime.migration] Running upgrade  -&gt; a6664359912e, Add user table
  INFO  [alembic.runtime.migration] Running upgrade a6664359912e -&gt; 6b7e8489b0ee, Add post table
  INFO  [alembic.runtime.migration] Running upgrade 6b7e8489b0ee -&gt; a8b409f2c772, Add fields to user table
  INFO  [alembic.runtime.migration] Running upgrade a8b409f2c772 -&gt; 2a3289732dbc, add followed field in user table
  INFO  [alembic.runtime.migration] Running upgrade 2a3289732dbc -&gt; d055880868f7, Add language field to post table
  [2020-10-30 09:54:42,426] INFO in __init__: Tinker ChatApp
  compiling catalog app/translations/sw/LC_MESSAGES/messages.po to app/translations/sw/LC_MESSAGES/messages.mo
  compiling catalog app/translations/zh/LC_MESSAGES/messages.po to app/translations/zh/LC_MESSAGES/messages.mo
  [2020-10-30 09:54:42 +0000] [1] [INFO] Starting gunicorn 20.0.4
  [2020-10-30 09:54:42 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
  [2020-10-30 09:54:42 +0000] [1] [INFO] Using worker: sync
  [2020-10-30 09:54:42 +0000] [12] [INFO] Booting worker with pid: 12
  Failed to find attribute 'app' in 'gossip_app'.
  [2020-10-30 09:54:42 +0000] [12] [INFO] Worker exiting (pid: 12)
  [2020-10-30 09:54:42 +0000] [1] [INFO] Shutting down: Master
  [2020-10-30 09:54:42 +0000] [1] [INFO] Reason: App failed to load.
  </code></pre>
  <p>My Flask app is structured as:</p>
  <pre><code>1_work_gossip_chat_app
                 |------------app/
                 |------------boot.sh
                 |------------Dockerfile
                 |------------config.py
                 |------------tinker.py
                 |------------requirements.txt
  </code></pre>
  <p>I created my image by updating the <code>Dockerfile</code> and the <code>boot.sh</code> file which acts as an executable, as seen below:</p>
  <p><code>Dockerfile</code></p>
  <pre class="lang-py prettyprint-override"><code>FROM python:3.8-alpine
  
  RUN adduser -D gossip_app
  
  WORKDIR /home/software_development/python/current_projects/1_work_gossip_chat_app
  
  COPY requirements.txt requirements.txt
  RUN python -m venv gossip_app
  RUN gossip_app/bin/python3 -m pip  install --upgrade pip
  
  RUN \
  # install psycopg2 dependancies
   apk update &amp;&amp; \
   apk add postgresql-dev gcc python3-dev musl-dev &amp;&amp; \
   # then install your requirements
   gossip_app/bin/pip3 install -r requirements.txt &amp;&amp; \
   gossip_app/bin/pip3 install gunicorn pymysql
  
  COPY app app
  COPY migrations migrations
  COPY tinker.py config.py boot.sh ./
  RUN chmod +x boot.sh
  
  ENV FLASK_APP tinker.py
  
  RUN chown -R gossip_app:gossip_app ./
  USER gossip_app
  
  EXPOSE 5000
  ENTRYPOINT [ &quot;./boot.sh&quot; ]
  </code></pre>
  <p><code>boot.sh</code></p>
  <pre class="lang-py prettyprint-override"><code>#!/bin/sh
  source gossip_app/bin/activate
  flask db upgrade
  flask translate compile 
  exec gunicorn -b :5000 --access-logfile - --error-logfile - gossip_app:app
  </code></pre>
  <p>I understand that from the error <code>gunicorn</code> is telling me that there is no Flask app instance in <code>gossip_app</code>. <code>gossip_app</code> to the best of my knowledge is the new user and also the new owner of the files and directories.</p>
  <p>What could I be getting wrong when creating this container?</p>
  <p>I have looked at several examples of how to build and run an image in Docker such as <a href="https://stackoverflow.com/questions/18497688/run-a-docker-image-as-a-container">this</a> and everything works very well, except for the one error I am admittedly struggling to debug for days on end.</p>