If the docker not restart on close maybe you set the wrong essential parameter value in task definition check the documentation.
To run apache in docker is using an other method:
Dockerfile:
…
ENTRYPOINT [“/entrypoint.sh”]
entrypoint.sh
…
exec apache2 -D FOREGROUND