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

CC BY-SA 4.0
2019-07-22T10:30:12.890Z
2019-07-22T10:30:12.890Z
Pyae Phyoe Shein
<p>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.</p>

<p>Here is <strong>appspec.yml</strong></p>

<pre><code>version: 0.0
os: linux
files:
  - source: /
    destination: /root/MY-BACKEND
    overwrite: true
hooks:
  BeforeInstall:
    - location: ./scripts/before_install.sh
      timeout: 300
      runas: root
  AfterInstall:
    - location: ./scripts/after_install.sh
      timeout: 300
      runas: root
  ApplicationStart:
    - location: ./scripts/app_start.sh
      timeout: 300
      runas: root
  ApplicationStop:
    - location: ./scripts/app_stop.sh
      timeout: 300
      runas: root
  ValidateService:
    - location: ./scripts/validate_server.sh
      timeout: 300
      runas: root
</code></pre>

<p>and <strong>after_install.sh</strong></p>

<pre><code>  cd /root/MY-BACKEND
  docker build -t my-backend .
</code></pre>

<p>and <strong>app_start.sh</strong></p>

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

<p>and <strong>validate_server.sh</strong></p>

<pre><code>  curl -m 5 http://0.0.0.0
</code></pre>

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

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

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

CC BY-SA 4.0
2019-07-15T02:52:55.663Z
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).
Dan Cornilescu
CC BY-SA 4.0
2019-07-15T03:54:54.717Z
I've got solution by myself now.
Pyae Phyoe Shein
CC BY-SA 4.0
2019-07-22T10:20:52.017Z
@PPShein Would be good if you could share this solution then.
Cyclonecode
CC BY-SA 4.0
2019-07-22T10:30:07.893Z
@Cyclonecode I've answered it by myself.
Pyae Phyoe Shein
<docker><amazon-web-services><aws-codedeploy><aws-codepipeline>
Docker container is running but when using curl not accessible
Pyae Phyoe Shein
# Docker container is running but when using curl not accessible

(Asked by: username_0 on 2019-07-14)

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
files:
  - source: /
    destination: /root/MY-BACKEND
    overwrite: true
hooks:
  BeforeInstall:
    - location: ./scripts/before_install.sh
      timeout: 300
      runas: root
  AfterInstall:
    - location: ./scripts/after_install.sh
      timeout: 300
      runas: root
  ApplicationStart:
    - location: ./scripts/app_start.sh
      timeout: 300
      runas: root
  ApplicationStop:
    - location: ./scripts/app_stop.sh
      timeout: 300
      runas: root
  ValidateService:
    - 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 http://0.0.0.0

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.

**Tags:** docker, amazon-web-services, aws-codedeploy, aws-codepipeline

> **Comments:**
> **username_1**: 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).  
> **username_0**: I've got solution by myself now.  
> **username_2**: @PPShein Would be good if you could share this solution then.  
> **username_0**: @username_2 I've answered it by myself.  

---

## 1 answers

### Answer by username_0 on 2019-07-22. Score: 0 | Accepted answer

I've found solution. Problem is backend took 10 mins to make fully loaded. When `curl -m 5 http://0.0.0.0` 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 http://0.0.0.0` inside **validate\_server.sh**, now it was working.


---

