Use the Docker plugin
This topic provides information on using the Docker plugin. he Docker plugin allows you to manage Docker containers and images, enabling you to integrate Docker operations into your deployment processes.
Deploy a Docker Container
- Create an application and a deployment package.
- Hover over the deployment package, click , click New, and then select
docker.ContainerSpec
. - Hover over the deployment package containing the new
docker.ContainerSpec
, click , click Deploy and select the target environment. - 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
- Create an application and a deployment package.
- Hover over the deployment package, click , click New, and then select
docker.Service
. - Hover over the deployment package containing the new
docker.Service
, click , click Deploy and select the target environment containing thedocker.SwarmManager
. - 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 ServiceVolumeMountSpec
- Create an application and a deployment package.
- Hover over the deployment package, click , click New, and then select docker > ServiceVolumeMountSpec.
- Provide Name and specify the Host Path and Target.
- Click Save and Close.
- Click Deploy to execute the plan.
Sample Manifest:
<?xml version="1.0" encoding="UTF-8"?>
<udm.DeploymentPackage version="1.0" application="DockerApp">
<application />
<orchestrator />
<deployables>
<docker.ServiceSpec name="/serviceSpec">
<tags />
<serviceName>tomcat</serviceName>
<image>bitnami/tomcat:10.5.20</image>
<labels />
<containerLabels />
<constraints />
<networks />
<environment />
<volumeMount>
<docker.ServiceVolumeMountSpec name="/serviceSpec/servicevolumesample">
<volumeName>testsample</volumeName>
<mountType>volume</mountType>
<hostPath>c:/software</hostPath>
<target>/usr/local/tmp</target>
</docker.ServiceVolumeMountSpec>
</volumeMount>
<portBindings />
</docker.ServiceSpec>
</deployables>
<applicationDependencies />
<dependencyResolution>LATEST</dependencyResolution>
<undeployDependencies>false</undeployDependencies>
<templates />
<boundTemplates />
</udm.DeploymentPackage>
Deploy a Docker Volume
Create an independent volume
- Create an application and a deployment package.
- Hover over the deployment package, click , click New, and then select
docker.VolumeSpec
. - Enter a name for the service in the Name field and specify a Volume Name for the volume.
- Hover over the deployment package containing the new
docker.VolumeSpec
, click , click Deploy and select the target environment. - Click Continue and then click Deploy to execute the plan.
- To connect to your Swarm Manager host, run this command:
docker-machine ssh <node_name>
- To check the service created, run this command:
docker ps -a
Attach a volume to a Docker container
- Hover over the created container, click , click New, and then select MountedVolumeSpec.
- 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.
- 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
- Create an application and a deployment package.
- Hover over the deployment package, click , click New, and then select
docker.NetworkSpec
. Perform the same action again to create adocker.ContainerSpec
. - In the Network Name field, specify the name of the private network that will be created.
- Click Save to create the network.
- For the created container, go to the Network tab and add the name of the network which will bind the
containers. - Deploy the application to the target environment.
- Log in to your Docker host and run this command:
docker network inspect <network_name>
- To verify if the network is created with the docker host, run this command:
docker network ls
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:
- Create a container inside an application with a deployment package.
- Hover over the created container, click , click New, and then select
PortSpec
. - 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.
- Deploy the application to the target environment.
- Log in to your Docker host and run this command:
docker network inspect <network_name>
- To verify if the network is created with the docker host, run this command:
docker network ls
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>