Skip to content

Elastic Beanstalk deployment fails when attempting to mount nginx config

0

When deploying to Elastic Beanstalk Docker, I'm getting the following error in the eb_engine log group. I'm running on AWS Linux 2023 and have tried creating a <app_root>/.platform/nginx/nginx.conf file on the machine I'm running eb deploy from.

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/var/app/current/nginx.conf" to rootfs at "/etc/nginx/conf.d/default.conf": mount /var/app/current/nginx.conf:/etc/nginx/conf.d/default.conf (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

Where should /var/app/current/nginx.conf be coming from? I also SSHed into the EC2 instance and found there is no /etc/nginx/conf.d/default.conf file (but the directory exists). Since the error indicates "Check if the specified host path exists", I'm guessing it's to do with the nginx.conf file missing from Elastic Beanstalk engine process, but am not sure how I might include it other than adding it to the .platform\nginx.

asked a year ago200 views
1 Answer
3

Considering below steps to address and fix the issue:

  • Correct Directory Structure: Ensure that your .platform/nginx/conf.d/ directory structure is correct. The configuration file should be placed in .platform/nginx/conf.d/elasticbeanstalk/.

  • File Permissions: Verify that the file permissions are set correctly. The Nginx configuration file should be readable by the Nginx process.

  • Container Commands: Add a container command to reload Nginx after configuration changes. Create a file named 00_myconf.config in the .platform/ directory with the following content:

container_commands:
  01_reload_nginx:
    command: "nginx -s reload"
  • Bundle Structure: Ensure that your application bundle includes the .platform/ directory and all necessary configuration files. When you zip your project for deployment, make sure the .platform/ folder is included.

  • Environment Rebuild: Sometimes, a rebuild of the environment is necessary to apply the changes. You can trigger a rebuild from the Elastic Beanstalk console.

  • Check Logs: Review the eb-engine.log for any additional error messages that might provide more insight into the issue.

EXPERT
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.