We start by creating a simple compose file; this example uses the nginx image that will serve a page that is in a directory that is passed into the container via a mount.
Note: The volume mount is relative to the root directory of where you will be building your zipfile. In our case, we will have a data directory that will be mounted into the container. This directory will be named data
and will be mounted read-only, although it is possible to make this mount read/write.
services:
web:
image: nginx
volumes:
- ./data:/usr/share/nginx/html:ro
ports:
- "80:80"
command: [nginx-debug, '-g', 'daemon off;']
Our page is a very simple HTML page that tells us that things worked.
<!DOCTYPE html>
<html>
<head>
<title>Included File Test</title>
</head>
<body>
<p>If you're seeing this, the included file worked...</p>
</body>
</html>
We now create a manifest file that provides a path to our compose file (in this case, we are only using one file but this method allows you to use multiple files if necessary).
dockercomposefiles:
- docker-compose.yml
Our directory structure looks like this:
├── data
│ └── index.html
├── docker-compose.yml
└── manifest.yml
We now create our zipfile:
$ zip -r compose-test.zip *
updating: data/ (stored 0%)
updating: docker-compose.yml (deflated 18%)
updating: data/index.html (deflated 32%)
adding: manifest.yml (deflated 17%)
Now, the file can either be uploaded to artifactory (preferred method, since it uses the artifactory security settings) or via a webserver. Note that if you use a webserver, the MeX will need to be able to access it, which does not allow for the use of authentication.
$ curl -q -u demo -T ./compose-test.zip https://artifactory.mobiledgex.net/artifactory/repo-demoorg/compose-test.zip
Enter host password for user 'demo':
{
"repo" : "repo-demoorg",
"path" : "/compose-test.zip",
"created" : "2020-05-21T15:42:12.759Z",
"createdBy" : "demo",
"downloadUri" : "https://artifactory.mobiledgex.net/artifactory/repo-demoorg/compose-test.zip",
"mimeType" : "application/zip",
"size" : "909",
"checksums" : {
"sha1" : "696ca6354935c0fabc2b4e9853b77d1d259412f3",
"md5" : "6075b505ca0e7417a213ccb8fe5c91d7",
"sha256" : "666eac3c030ba5a58e738e4b79f7f326c14fcecb38a3284fb3c1d5510fcddcc1"
},
"originalChecksums" : {
"sha256" : "666eac3c030ba5a58e738e4b79f7f326c14fcecb38a3284fb3c1d5510fcddcc1"
},
"uri" : "https://artifactory.mobiledgex.net/artifactory/repo-demoorg/compose-test.zip"
}
Once you have received confirmation in the form of the json blob returned above, you can move on to the steps for deploying a docker instance through the MeX console. There are two important things to keep in mind:
Image Path
field blank in the console.Deployment Manifest
entrybox. For example, the above Zip file should be referenced as https://artifactory.mobiledgex.net/artifactory/repo-demoorg/compose-test.zip