I am a student, and I am currently trying to deploy my Django application on Docker Ubuntu using Nginx and Gunicorn. However, when I restart the container, both Nginx and Gunicorn are also turned off. I have to use the command "docker attach " to enter the container and run the commands service nginx start
and systemctl start gunicorn
. Is there any way to automatically start Nginx and Gunicorn when the container is restarted? Thank you sincerely.
[This is the configuration file.](https://i.stack.imgur.com/HC7Ol.png)
I have tried writing a start.sh file like this:
#!/bin/bash
# Start Nginx
service nginx start
# Start Gunicorn
systemctl start gunicorn
exec "$@"
and Dockerfile
FROM my_image
COPY start.sh /start.sh
RUN chmod +x /start.sh
EXPOSE 80
CMD ["/start.sh"]