canonical / ubuntu.com

The official website for the Ubuntu operating system
https://ubuntu.com
Other
201 stars 199 forks source link

Error when running website locally with `dotrun` #14229

Closed skoech closed 1 month ago

skoech commented 2 months ago

Summary

When trying to run the website locally using dotrun, I run into this:

Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied')) Dotrun needs Docker to work, please check if Docker is installed and running

I have Docker installed and running:

$ systemctl status docker

● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset>
     Active: active (running) since Mon 2024-08-26 16:40:45 EAT; 1h 45min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 663100 (dockerd)
      Tasks: 25
     Memory: 58.0M
        CPU: 16.748s
     CGroup: /system.slice/docker.service
             └─663100 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/co>

Ago 26 16:40:44 skoech dockerd[663100]: time="2024-08-26T16:40:44.379159905+03:>
Ago 26 16:40:45 skoech dockerd[663100]: time="2024-08-26T16:40:45.209085982+03:>
Ago 26 16:40:45 skoech dockerd[663100]: time="2024-08-26T16:40:45.243378096+03:>
Ago 26 16:40:45 skoech dockerd[663100]: time="2024-08-26T16:40:45.261467663+03:>
Ago 26 16:40:45 skoech dockerd[663100]: time="2024-08-26T16:40:45.398860420+03:>
Ago 26 16:40:45 skoech dockerd[663100]: time="2024-08-26T16:40:45.460055196+03:>
Ago 26 16:40:45 skoech dockerd[663100]: time="2024-08-26T16:40:45.460222975+03:>
Ago 26 16:40:45 skoech dockerd[663100]: time="2024-08-26T16:40:45.537995926+03:>
Ago 26 16:40:45 skoech systemd[1]: Started Docker Application Container Engine.
Ago 26 16:48:05 skoech dockerd[663100]: time="2024-08-26T16:48:05.157609598+03:>

Steps to reproduce the behavior

Running dotrun on git repo.

Expected behavior

Server starting, being able to access website locally on http://127.0.0.1:8001/.

Browser/device details

Reported from

GitHub

mtruj013 commented 2 months ago

Hi @skoech, thanks for reporting. This is an issue with the docker python package. You can solve it by adding a couple of lines to your basehttpadapter.py file. Should look like this:

import requests.adapters

class BaseHTTPAdapter(requests.adapters.HTTPAdapter):
    def close(self):
        super().close()
        if hasattr(self, 'pools'):
            self.pools.clear()
    #  new: add these 2 lines
    def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):
        return self.get_connection(request.url, proxies)

To find the file location you can do:

  1. pip3 show docker
  2. grab the Location path from that output and add docker/transport/basehttpadapter.py to it. So for example for me this would be /usr/local/lib/python3.10/dist-packages/docker/transport/basehttpadapter.py

Please give that a try and let us know if it worked, thanks

skoech commented 2 months ago

Hi @mtruj013, thanks so much for your prompt and detailed response. I have tried this solution but I am still getting the same error. I also noticed that the get_connection method is deprecated and tried with get_connection_with_tls_context() instead.

lizzochek commented 1 month ago

@skoech please try running docker desktop before running dotrun and let us know if it helps

immortalcodes commented 1 month ago

Hi, Please ensure if you have docker up and running, if that is the case then you should try using sudo as it might be the case that docker installation in your system may require root permissions. Please let me know if you need more information on any of this. Thanks

immortalcodes commented 1 month ago

I hope this has been resolved but if not please feel free to contact-us or re-open this issue. Thanks