xxxxxxxxxx
import subprocess
def restart_docker_service():
subprocess.call(["systemctl", "restart", "docker"])
# Call the function to restart the Docker service
restart_docker_service()
xxxxxxxxxx
#Flush changes and restart Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
xxxxxxxxxx
$ sudo systemctl restart docker.socket docker.service
$ docker rm {container_id}