Valid since:
XL Deploy 6.2.0

Deploy a Docker Container

  1. Create an application and a deployment package.
  2. Hover over the deployment package, click Explorer action menu, click New, and then select docker.ContainerSpec.
  3. Hover over the deployment package containing the new docker.ContainerSpec, click Explorer action menu, click Deploy and select the target environment.
  4. Click Continue and then click Deploy to execute the plan.

Sample Manifest:

  <?xml version="1.0" encoding="UTF-8"?>
  <udm.DeploymentPackage version="demo_docker_host" application="demo_create_container_app">
      <application />
      <orchestrator />
      <deployables>
        <docker.ContainerSpec name="/nginx_container">
            <tags />
            <containerName>demo_nginx</containerName>
            <image>nginx</image>
            <labels />
            <environment />
            <restartPolicyMaximumRetryCount>40</restartPolicyMaximumRetryCount>
            <networks />
            <dnsOptions />
            <links />
            <portBindings />
            <volumeBindings />
        </docker.ContainerSpec>
      </deployables>
      <applicationDependencies />
      <dependencyResolution>LATEST</dependencyResolution>
      <undeployDependencies>false</undeployDependencies>
  </udm.DeploymentPackage>

Deploy a Docker Service

  1. Create an application and a deployment package.
  2. Hover over the deployment package, click Explorer action menu, click New, and then select docker.Service.
  3. Hover over the deployment package containing the new docker.Service, click Explorer action menu, click Deploy and select the target environment containing the docker.SwarmManager.
  4. Click Continue and then click Deploy to execute the plan.

Sample Manifest:

  <?xml version="1.0" encoding="UTF-8"?>
  <udm.DeploymentPackage version="docker_swarm" application="docker_swarm_demo_app">
      <application />
      <orchestrator />
      <deployables>
        <docker.ServiceSpec name="/tomcat_service">
            <tags />
            <serviceName>tomcat-service</serviceName>
            <image>tomcat</image>
            <labels />
            <containerLabels />
            <constraints />
            <waitForReplicasMaxRetries>30</waitForReplicasMaxRetries>
            <networks />
            <environment />
            <restartPolicyMaximumRetryCount>30</restartPolicyMaximumRetryCount>
            <portBindings />
        </docker.ServiceSpec>
      </deployables>
      <applicationDependencies />
      <dependencyResolution>LATEST</dependencyResolution>
      <undeployDependencies>false</undeployDependencies>
  </udm.DeploymentPackage>

Note You can only deploy a docker service to a docker swarm.

Deploy a Docker Volume

Create an independent volume

  1. Create an application and a deployment package.
  2. Hover over the deployment package, click Explorer action menu, click New, and then select docker.VolumeSpec.
  3. Enter a name for the service in the Name field and specify a Volume Name for the volume.
  4. Hover over the deployment package containing the new docker.VolumeSpec, click Explorer action menu, click Deploy and select the target environment.
  5. Click Continue and then click Deploy to execute the plan.
  6. Run this command docker-machine ssh <node_name> to connect to your Swarm Manager host and run this command docker ps -a to check the service created.

Attach a volume to a Docker container

  1. Hover over the created container, click Explorer action menu, click New, and then select MountedVolumeSpec.
  2. Enter a name for the application version, specify a name for the volume, enter the directory of the docker container where the volume will be attached in the Mountpoint field, and the default value false in the Read Only field.
  3. Deploy the created package to the target environment.

The Docker container is created with the mounted volume attached at the mount point.

Sample Manifest:

  <?xml version="1.0" encoding="UTF-8"?>
  <udm.DeploymentPackage version="docker_volume" application="docker_volume_demo">
      <application />
      <orchestrator />
      <deployables>
        <docker.VolumeSpec name="/test_volume">
            <tags />
            <volumeName>testvolume</volumeName>
            <driverOptions />
            <labels />
        </docker.VolumeSpec>
        <docker.ContainerSpec name="/nginx_container">
            <tags />
            <containerName>nginx-container</containerName>
            <image>nginx</image>
            <labels />
            <environment />
            <networks />
            <dnsOptions />
            <links />
            <portBindings />
            <volumeBindings>
        <docker.MountedVolumeSpec name="/nginx_container/testvolume">
            <volumeName>testvolume</volumeName>
            <mountpoint>/tmp</mountpoint>
        </docker.MountedVolumeSpec>
        </volumeBindings>
        </docker.ContainerSpec>
      </deployables>
      <applicationDependencies />
      <dependencyResolution>LATEST</dependencyResolution>
      <undeployDependencies>false</undeployDependencies>
    </udm.DeploymentPackage>

Create a Docker Network

  1. Create an application and a deployment package.
  2. Hover over the deployment package, click Explorer action menu, click New, and then select docker.NetworkSpec. Perform the same action again to create a docker.ContainerSpec.
  3. In the Network Name field, specify the name of the private network that will be created.
  4. Click Save to create the network.
  5. For the created container, go to the network tab and add the name of the network which will bind the
    containers.
  6. Deploy the application to the target environment.
  7. Log in to your Docker host and run this command docker network inspect <network_name>.
  8. Run this command docker network ls to verify if the network is created with the docker host.

Map a Docker container port to a Docker host

Port mapping is used to map the host port with the container port.

To create a port mapper:

  1. Create a container inside an application with a deployment package.
  2. Hover over the created container, click Explorer action menu, click New, and then select PortSpec.
  3. Enter a name for the application version, in the Host Port field, enter the port of the Docker host that will be mapped to the container, the container port, and specify the protocol over which the connection will be established.
  4. Deploy the application to the target environment.
  5. Log in to your Docker host and run this command docker network inspect <network_name>.
  6. Run this command docker network ls to verify if the network is created with the docker host.

Sample Manifest:

    <?xml version="1.0" encoding="UTF-8"?>
    <udm.DeploymentPackage version="network_package" application="docker_demo_network">
        <application />
        <orchestrator />
        <deployables>
        <docker.NetworkSpec name="/custom_network">
          <tags />
        <networkName>custom_network</networkName>
        <networkOptions />
        </docker.NetworkSpec>
        <docker.ContainerSpec name="/mysql-container">
          <tags />
        <containerName>mysql-container</containerName>
        <image>mysql</image>
        <labels />
        <environment />
        <networks>
        <value>custom_network</value>
        </networks>
        <dnsOptions />
        <links />
        <portBindings>
        <docker.PortSpec name="/mysql-container/port_map">
          <hostPort>92</hostPort>
        <containerPort>80</containerPort>
        <protocol>tcp</protocol>
        </docker.PortSpec>
        </portBindings>
        <volumeBindings />
        </docker.ContainerSpec>
        </deployables>
        <applicationDependencies />
        <dependencyResolution>LATEST</dependencyResolution>
    <undeployDependencies>false</undeployDependencies>
    </udm.DeploymentPackage>