Let's say something like this is being returned.
the app mountpoint must be a string
*** no app loaded. GAME OVER ***
I got this when attempting to run a Docker image that contained a Python Flask app.
sudo docker run \
--detach \
--restart unless-stopped \
--name my-container \
--publish 10.11.12.13:12345:80 \
my-org/my-image:0.0.1
It look quite a bit of testing for me to identify that I ran into this problem when my Flask __init__.py file had the following. Notice that in the try/except error handling block, I define a message (line 14) but I forgot to print the message, thus the Docker logs didn't contain a log telling me what the issue was. Basically, user error. I forgot the print statement.
1 import boto3, os
2 from flask import Flask
3
4 def app():
5 app = Flask(__name__, static_url_path='', static_folder='static/', template_folder='templates/')
6
7 os.environ['AWS_SHARED_CREDENTIALS_FILE'] = '/usr/local/.aws/credentials'
8 os.environ['AWS_PROFILE'] = "john.doe"
9 os.environ['AWS_DEFAULT_REGION'] = 'us-west-2'
10
11 try:
12 client = boto3.client('secretsmanager')
13 except Exception as exception:
14 message = f"got the following exception when trying boto3.client('secretsmanager') => {exception}"
15
16 return app
I added the missing print statement (line 15).
1 import boto3, os
2 from flask import Flask
3
4 def app():
5 app = Flask(__name__, static_url_path='', static_folder='static/', template_folder='templates/')
6
7 os.environ['AWS_SHARED_CREDENTIALS_FILE'] = '/usr/local/.aws/credentials'
8 os.environ['AWS_PROFILE'] = "john.doe"
9 os.environ['AWS_DEFAULT_REGION'] = 'us-west-2'
10
11 try:
12 client = boto3.client('secretsmanager')
13 except Exception as exception:
14 message = f"got the following exception when trying boto3.client('secretsmanager') => {exception}"
15 print(message)
16
17 return app
And then saw the following in the log.
botocore.exceptions.ProfileNotFound: The config profile (john.doe) could not be found
And this was occurring because the /usr/local/.aws/credentials and config files in the container were only readable by root.
~]$ sudo docker exec my-container ls -l /usr/local/.aws
total 8
-rw-------. 1 root root 315 Nov 29 10:52 config
-rw-------. 1 root root 835 Nov 29 10:52 credentials
Which was resolved by adding the following to the Dockerfile used to create the image, so that the credentials and config file were readable by www-data user, which is the user running uwsgi in the container.
RUN chown -R www-data:www-data /usr/local/.aws
Did you find this article helpful?
If so, consider buying me a coffee over at 