I tried to host docker container in my EC2, just for UAT (for production, we will fargate). My concern is I want to host my container in EC2 and run all test cases, after successfully will be deployed to fargate.

Here is appspec.yml

version: 0.0
os: linux
  - source: /
    destination: /root/MY-BACKEND
    overwrite: true
    - location: ./scripts/before_install.sh
      timeout: 300
      runas: root
    - location: ./scripts/after_install.sh
      timeout: 300
      runas: root
    - location: ./scripts/app_start.sh
      timeout: 300
      runas: root
    - location: ./scripts/app_stop.sh
      timeout: 300
      runas: root
    - location: ./scripts/validate_server.sh
      timeout: 300
      runas: root

and after_install.sh

  cd /root/MY-BACKEND
  docker build -t my-backend .

and app_start.sh

  cd /root/MY-BACKEND
  docker run -d -p 80:2019 --name my-docker my-backend

and validate_server.sh

  curl -m 5

After that, I've encountered following error message from Validate Server [stderr]curl: (52) Empty reply from server

And when changed to curl -m 5 http://localhost, encountered following error message [stderr]curl: (56) Recv failure: Connection reset by peer

But when I open browser, my app is working either tried curl from my local and remote server, both are working. Please let me know which I missed to add some validation.

  • Often browsers do more stuff than curl when trying to access a particular URL. Open the browser's development tools (maybe in an incognito window) and re-load that url to see what it's doing (authentication, session setup, etc). Then try to adjust curl's options to do the same thing. Also the environment in which scripts are executed typically differs between automated tools and user-invoked (for example user invocations use an interactive shell session, automated tools do not). Jul 15, 2019 at 2:52
  • I've got solution by myself now.
    – PPShein
    Jul 15, 2019 at 3:54
  • @PPShein Would be good if you could share this solution then. Jul 22, 2019 at 10:20
  • @Cyclonecode I've answered it by myself.
    – PPShein
    Jul 22, 2019 at 10:30

1 Answer 1


I've found solution. Problem is backend took 10 mins to make fully loaded. When curl -m 5 in validate_server.sh, backend is not ready yet to response back that's why [stderr]curl: (56) Recv failure: Connection reset by peer throw. So, I've added sleep 20s above curl -m 5 inside validate_server.sh, now it was working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.