Docker-compose failed to restart inside ubuntu image

Im trying to host web app inside docker container and for it i need docker-compose in docker. I installed docker-compose inside ubuntu image and that solution worked! (im running container with privileged mode)

Image file:

Entrypoint:
#!/bin/bash
sudo service docker start
sudo nginx -g daemon off;
sudo service nginx restart
cd /home/docker && sudo docker-compose up

But if i want to restart container with docker restart or sudo docker restart it throws this error:
docker.errors.DockerException: Error while fetching server API version: (‘Connection aborted.’, ConnectionRefusedError(111, ‘Connection refused’))
[128] Failed to execute script docker-compose

Full error:
docker-compose error - Pastebin.com

*First container boot is successful

Any suggestions?