Can you add this code before pulling the ecs-agent.
until docker info >/dev/null 2>&1; do echo "waiting for the docker to be ready" sleep 5 done echo "docker is ready"