dockerblueprintcloudify

how to edit blueprint for automatically running a command in docker container run by cloudify


I want to run a docker container of RYU controller in cloudify ways. I have written a blueprint file with which I can create relevant deployment and finally start the docker container.

The problem is, the controller (within the docker container) needs to implement a script to function but I don't know how to modify the blueprint file for automatically running the script. Every time, I have to type docker exec CONTAINER ryu-manager /path/simple_switch.py for the goal.

So does anyone know where the command should be put in the blueprint. I tried to include it in

interfaces:
  cloudify.interfaces.lifecycle:
    create:
      implementation: docker.docker_plugin.tasks.create_container
      inputs:
        params:
          ports:
            - { get_input: docker_port }
          stdin_open: true
          tty: true
          command: /bin/bash

    start:
      implementation: docker.docker_plugin.tasks.start
      inputs:
        params:
          port_bindings: { get_input: container_port_binding }
          command: docker exec ryu ryu-manager /ryu/ryu/app/simple_switch.py
          # here ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ 

but received an error of unexpected parameter.

Thanks for your time and any opinions would be appreciated~


Or let me put in this way, if anyone knows, which part in the cloudify blueprint matches docker exec?


Solution

  • I use Cloudify a lot and I use Docker a lot. The Docker Plugin is kind of "nice to have", but it is really not necessary. You can just run commands like "docker exec" and "docker run" from inside of the the Cloudify Script plugin and get the same result, and you do not need to figure out a different interface for working with Docker.

    For example if I have this cloudify blueprint (simplified):

    yaml node_templates: my_app: type: cloudify.nodes.SoftwareComponent interfaces: cloudify.interfaces.lifecycle: create: implementation: scripts/create.sh start: implementation: scripts/start.sh relationships: - type: cloudify.relationships.depends_on target: vm

    I can call such scripts:

    scripts/create.sh:

    docker run -d ryu

    scripts/start.sh

    docker exec -it ryu ryu-manager /ryu/ryu/app/simple_switch.py