Example of Building an Application with vSphere Integrated Containers Engine
The example in this topic modifies the voting app by Docker to illustrate how to work around the constraints that the current version of vSphere Integrated Containers Engine imposes. For information about the constraints, see Constraints of Using vSphere Integrated Containers Engine with Docker Compose.
This example focuses on how to modify the Docker Compose YML file from the voting app to make it work with vSphere Integrated Containers. It does not describe the general function or makeup of the voting app.
- Clone the Docker voting app repository from https://github.com/docker/example-voting-app.
- Open the YML file for the simple Docker voting app,
version: "2" services: vote: build: ./vote command: python app.py volumes: - ./vote:/app ports: - "5000:80" redis: image: redis:alpine ports: ["6379"] worker: build: ./worker db: image: postgres:9.4 result: build: ./result command: nodemon --debug server.js volumes: - ./result:/app ports: - "5001:80" - "5858:5858"
This compose file uses two features that this version of vSphere Integrated Containers does not support:
- Mapping of local folders to container volumes
To allow the voting app to work with vSphere Integrated Containers, you must modify it to work around these constraints.
Modify the Application
This version of vSphere Integrated Containers Engine does not support the
docker build or
push commands. Use regular Docker to perform the steps in this section.
NOTE: It is possible to build and tag an image in one step. In this example, building and tagging are in separate steps.
Build images for the different components of the application.
cd example-voting-app docker build -t vote ./vote docker build -t vote-worker ./worker docker build -t vote-result ./result
Tag the the images to upload them to your private registry or to your personal account on Docker Hub.
This example uses a Docker Hub account. Replace dockerhub_username with your own account name in the commands below.
docker tag vote dockerhub_username/vote docker tag vote-worker dockerhub_username/vote-worker docker tag vote-result dockerhub_username/vote-result
Push the images to the registry.
docker login [Provide credentials] docker push dockerhub_username/vote docker push dockerhub_username/vote-worker docker push dockerhub_username/vote-result
docker-compose-simple.ymlfile in an editor and modify it to remove the operations that vSphere Integrated Containers does not support.
- Remove local folder mapping
- Remove all of the build directives
- Update dockerhub_username to your Docker Hub account name
- Save the modified file with the name
The example below shows an excerpt of the YML file after the modifications:
version: "2" services: vote: image: dockerhub_username/vote command: python app.py ports: - "5000:80" redis: image: redis:alpine ports: ["6379"] worker: image: dockerhub_username/vote-worker db: image: postgres:9.4 result: image: dockerhub_username/vote-result command: nodemon --debug server.js ports: - "5001:80" - "5858:5858"
You can download the modified YML file from the vSphere Integrated Containers Engine repository on Github from https://github.com/vmware/vic/blob/master/demos/compose/voting-app.
Deploy the Application to a VCH
The steps in this section make the following assumptions:
- You have deployed a virtual container host (VCH).
- You deployed the VCH with a volume store named
- You deployed the VCH with the
--no-tlsoption, to disable TLS authentication between the Docker client and the VCH.
- You are using Docker Compose 1.8.1.
In the procedure below, run the commands from the
example-voting-app folder that contains the modified