Docker on the controller node

asked 2019-01-07 09:40:51 -0600

najeh gravatar image

updated 2019-01-08 02:24:40 -0600

I tried to connect to an openstack instance and manage containers inside it from the controller node. This is my code :

#connect_instance.py

import paramiko
from connection import connect

def initiate():

  connect()
  ssh = paramiko.SSHClient()
  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  ssh.connect(hostname='192.168.1.x',
            username='ubuntu',
            key_filename='mykey.pem')
  cmd = "python ~/application/DockerProgramming.py"
  stdin, stdout, stderr = ssh.exec_command(cmd)
  stdin.close() 
  return stdout.read()

initiate()

ps: DockerProgramming.py create a new container and connection.py connect to the openstack cloud

==> when running connect_instance.py from the controller node i got these errors:

Traceback (most recent call last):
  File "/root/application/manageInstance.py", line 28, in <module>
    initiate()
  File "/root/application/manageInstance.py", line 20, in initiate
    stdin, stdout, stderr = ssh.exec_command(create_container())
  File "/root/application/DockerProgramming.py", line 24, in create_container
    client.containers.run('kepler/kepler', detach=True)
AttributeError: 'function' object has no attribute 'run'

So, should i install docker on the controller node to run a python program that manage docker containers in an openstack instance ?

edit retag flag offensive close merge delete