Error in executing docker program in a remote instance

When i tried to run a python script from a local machine in a remote machine using this command:

sudo ssh -i mykey.pem ubuntu@192.168.x.x python < /root/application/DockerProgramming.py

i recieved these errors:

Traceback (most recent call last):
File “”, line 22, in
File “”, line 19, in create_container
File “/usr/local/lib/python2.7/dist-packages/docker/models/containers.py”, line 912, in list
since=since)
File “/usr/local/lib/python2.7/dist-packages/docker/api/container.py”, line 205, in containers
res = self._result(self._get(u, params=params), True)
File “/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py”, line 46, in inner
return f(self, *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/docker/api/client.py”, line 215, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File “/usr/local/lib/python2.7/dist-packages/requests/sessions.py”, line 546, in get
return self.request(‘GET’, url, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/adapters.py”, line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, error(13, ‘Permission denied’))

Where is the problem and how can i solve it ?

Seems like the Ubuntu host you ssh into does not have the ubuntu user as a member of the docker group so it can’t run the docker commands to the dockerd without sudo. Try running the python command with sudo or add the ubuntu-user to docker group according to https://docs.docker.com/install/linux/linux-postinstall/.

/O

2 Likes