DockerApp

You can launch servers which run Docker containers containing your applications and services. To do that you define DockerApp nodes in the node_templates: section of your templates. The DockerApp node when instructed by Dell Cloud Manager will pull images from Docker repositories and create, start, stop and delete docker containers.

You can launch servers from images with Docker pre-installed or you can install Docker along with installing the DCM agent using the agent_docker.sh bash script.

The Docker node is defined with a section name, a type and properties.

section name

Example: docker_app:

type

type: dcm.nodes.DockerApp

properties

The following node properties are supported when defining a Docker node in a blueprint template:

  • image - Docker image repository (e.g. ubuntu, gforghetti/apache)
  • tag - image to launch from the Docker image repository (e.g. latest)
  • ports - ports to expose (ports the docker container will use). This maps to the Dockerfile EXPOSE statement.
  • portBindings - one or more ports to be bound from the docker container to the launched server which is running docker. This maps to the -p parameter on the Docker run command.
  • runCommand - command to run on the docker container. This maps to the Dockerfile CMD statement.
  • environmentVariables - one or more environment variables to pass to the docker container. This maps to the Dockerfile ENV statement.
  • links - defines a link to another docker container.
  • target-container-name: link-name

Example 1

  docker_app:
    type: dcm.nodes.DockerApp
    properties:
      image: dell/mysql
      tag: 1.1
      runCommand: '/run.sh'
      ports: [3306]
      password: {get_random_str: [10]}
      portBindings:
        3306: [['0.0.0.0', 3306]]
      environmentVariables:
        DEBIAN_FRONTEND: noninteractive
        MYSQL_USER: admin
        MYSQL_PASS: {get_property: [SELF, password]}
        REPLICATION_MASTER: '**False**'
        REPLICATION_SLAVE: '**False**'
        REPLICATION_USER: replica
        REPLICATION_PASS: replica

Example 2

This is an example of running two docker containers on a launched server and linking the two containers.

    ##################################################################################################################################################
    # This node_template defines a Docker application which will launch a container to run the MySQL server docker image
    ##################################################################################################################################################
    docker_db:
      type: dcm.nodes.DockerApp                                   # This is a DockerApp node
      properties:
        name: "mysql-wildbook"                                    # Name of the container
        image: 'mysql'                                            # Launch the mysql image from the Docker base repository
        tag: 'latest'                                             # Launch the latest image 
        portBindings:
          3306: [['0.0.0.0', 3306]]                               # Bind port 3306 on the container to port 3306 on the launched server from any incoming connection
        environmentVariables:
          MYSQL_ROOT_PASSWORD: "passw0rd"                         # MySQL root password
          MYSQL_DATABASE: "shepherd"                              # MySQL database
          MYSQL_USER: "shepherd"                                  # MySQL database user
          MYSQL_PASSWORD: "shepherd"                              # MySQL database user password

      requirements:
        - host: docker_vm                                         # This DockerApp node has a requirement on the docker_vm node (launched server)

    ##################################################################################################################################################
    # This node_template defines a Docker application which will launch a container to run the Tomcat Wildbook Application docker image
    ##################################################################################################################################################
    docker_app:
      type: dcm.nodes.DockerApp                                   # This is a DockerApp node
      properties:
        name: "tomcat-wildbook"                                   # Name of the container
        image: 'gforghetti/tomcat-wildbook'                       # Launch an image from the Docker user gforghetti repository tomcat-wildbook    
        tag: 'latest'                                             # Launch the latest image in that user repository  
        ports: [8080]                                             # Expose port 8080 (the container will use the http port 8080)
        portBindings:
          8080: [['0.0.0.0', 8080]]                               # Bind port 8080 on the container to port 8080 on the launched server from any incoming connection
        links: 
          mysql-wildbook: "mysql-wildbook"                        # Link this container to the Docker mysql-wildbook container with an link name of mysql-wildbook

      requirements:
        - host: docker_vm                                         # This DockerApp node has a requirement on the docker_vm node (launched server)
        - db: docker_db                                           # This DockerApp node also has a requirement on the docker_db container.
          relationship_type: tosca.relationships.DependsOn        # This DockerApp node has a dependsOn relationship to the docker_db container.

Note

Refer to the section in this document Samples using Docker to see an example of a template which uses Docker to deploy services and applications in docker containers on launched servers.