The nginx_phpfpm container goes unhealth when running on ECS as task - docker

Why is it really happening on AWS ECS? I have tested the docker image locally before pushing it to ECR. It works so smooth and is healthy.
Now, if I send the same image to ECR and run it as task, setting up the task definition in ECS. Its stopping and running back every time after few period of time.
The health status shows unhealthy. I am not using the ALB for health check but using the docker health check service built in with ECS. I though it might be the command issue so tried all the options hinted by people online.
CMD-SHELL, curl -f http://localhost/ || exit 1
But nothing seems working here.
What might be the exact cause the docker image running so well locally
does not run on ECS?
I even though, may be its not running on background so added this command on Entrypoint setting in task definition of ECS.
systemctl start nginx

Related

Docker build images and run but gives Error response from daemon: i/o timeout error after 5 minutes

I am trying to build and run 8 docker images via docker-compose. Some of them Java Spring projects and some of them angular projects. I am working under corporate proxy. I set proxy settings and docker works correctly. I can build and run images via docker-compose up -d --build command. I can see the logs at first. However after 3-5 minutes, when I tried to run docker ps or docker logs commands I got this error: Error response from daemon: i/o timeout . I tried to find the solution but every question was about the problem occurs during build process which is not my case.
Every time I restart docker, down the services then run the services without problem but after 5 minutes I can not run any docker command. How can I permanently fix this issue. Thanks for any help.

Docker container in ECS Fargate exits with code 0 when running script. Unable to run container to get to /bin/sh

I have an ECS Cluster that is using an image hosted in AWS ECR. The dockerfile is executing a script in it's entrypoint attribute. My cluster is able to spin up instances but then goes into a stopped state. The only error it is giving me is as follows:
Exit Code 0
Entry point ["/tmp/init.sh"]
The only information given to me is the reason the container stopped:
Stopped reason Essential container in task exited
Any advice on how I can fix this would be helpful.
I tried running the container locally using the following: docker run -it application /bin/sh
For some reason running the container, I am unable to get to in using /bin/sh.
Any advice would be appreciated.
What does the init.sh script do? That message isn't bad necessarily. It may just mean that your script has completed and no background process has started so your container is exiting.
You could run the container locally gaining a shell (as you did) and launch the script manually from there or you could just run the container without /bin/sh and let the script execute to see what happens. If the script exits locally as well then that seems to be the proper behavior and anything you'd need to debug you can debug locally.

celery beat container gets stuck

I started running a celery beat worker in a dedicated container. This works fine sometimes, but now I get the following error trying to remove or re-deploy my containers:
An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60).
Also, I cannot access the container anymore and the following commands just get stuck:
docker restart beat
docker logs beat
docker exec beat bash

how get logs for docker service tasks on "preparing" state

I'm playing around now with docker 1.12, created a service and noticed there is a stage of "preparing" when I ran "docker service tasks xxx".
I can only guess that on this stage the images are being pulled or updated.
My question is: how can I see the logs for this stage? Or more generally: how can I see the logs for docker service tasks?
I have been using docker-machine for emulating different "hosts" in my development environment.
This is what I did to figure out what was going on during this "Preparing" phase for my services:
docker service ps <serviceName>
You should see the nodes (machines) where your service was scheduled to run. Here you'll see the "Preparing" message.
Use docker-machine ssh to connect to a particular machine:
docker-machine ssh <nameOfNode/Machine>
Your prompt will change. You are now inside another machine.
Inside this other machine do this:
tail -f /var/log/docker.log
You'll see the "daemon" log for that machine.
There you'll see if that particular daemon is doing the "pull" or what's is doing as part of the service preparation.
In my case, I found something like this:
time="2016-09-05T19:04:07.881790998Z" level=debug msg="pull progress map[progress:[===========================================> ] 112.4 MB/130.2 MB status:Downloading
Which made me realise that it was just downloading some images from my docker account.
Your assumption (about pulling during preparation) is correct.
There is no log command yet for tasks, but you could certainly connect to that daemon and do docker logs in the regular way.

Docker Error: push is already in progress

I'm trying to push a container that was interrupted previously by a network drop out. But I get this error:
Error: push rimian/ruby-node-npm is already in progress
But when I run docker ps I don't see anything running.
What shall I do?
Restart the docker service on which you are running the docker.
With ubuntu:
sudo service docker restart
Just wait.
I had this once, too, and the problem is that the push is still running in the background, hence you can't do another one.
So just wait, and the problem will disappear automatically after some time.
The fact that you do not see anything running with docker ps is that this command only shows docker containers, not internal docker processes. And pushing an image is not run by a container.

Resources