0

I am trying to deploy a few docker containers on a DC/OS. I was successfully able to deploy a simple docker container. But I need to deploy a container with some additional parameters attached to it. Like attaching a directory like a volume and setting some environment variable. In docker, it is achieved by running the following command.

sudo docker run --name nifi-ssl \
  -v /home/azureuser/docker_nifi/nifi_stores:/opt/certs \
  -p 8443:8443 \
  -e NIFI_WEB_PROXY_HOST="some dns":8443 \
  -e AUTH=tls \
  -e KEYSTORE_PATH=/opt/certs/keystore.jks \
  -e KEYSTORE_TYPE=JKS \
  -e KEYSTORE_PASSWORD="somevalue"  \
  -e TRUSTSTORE_PATH=/opt/certs/truststore.jks \
  -e TRUSTSTORE_PASSWORD="somevalue" \
  -e TRUSTSTORE_TYPE=JKS \
  -e INITIAL_ADMIN_IDENTITY='CN=sys_admin, OU=NIFI' \
  -d \
  apache/nifi:latest

I need to set these kinda parameters in the marathon definition that I create for deploying the container. A marathon app definition for a simple container is as follows.

{
  "id": "nifi",
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "apache/nifi:latest"
    },
    "portMappings": [
      { "hostPort": 8080, "containerPort": 8080, "protocol": "tcp" }
    ]
  },
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "acceptedResourceRoles": ["slave_public"],
  "instances": 1,
  "cpus": 0.1,
  "mem": 5120
}

My question is how do I translate the above docker command to the marathon app definition so that when I deploy it, the resultant container is like what I would get if I ran the docker command

1 Answers1

0

Well, I figured out the problem myself, here is the solution, just in case someone else wants to do something similar. Below is the DCOS Marathon app config I used to deploy the container.

{
  "id": "nifi-ssl",
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "apache/nifi:latest",
      "parameters": [
            { "key": "volume", "value": "/home/centos/nifi_stores:/opt/certs" }
        ]

    },
    "portMappings": [
      { "hostPort": 8080, "containerPort": 8080, "protocol": "tcp" },
      { "hostPort": 9006, "containerPort": 9006, "protocol": "tcp" }
    ]
  },
  "env": {
    "NIFI_WEB_HTTPS_PORT": "9006",
    "NIFI_WEB_PROXY_HOST": "<DCOS cluster public agent dns name>:9006",
    "AUTH": "tls",
    "KEYSTORE_PATH": "/opt/certs/keystore.jks",
    "KEYSTORE_TYPE": "JKS",
    "KEYSTORE_PASSWORD": "passwordfromnifi.properties",
    "TRUSTSTORE_PATH": "/opt/certs/truststore.jks",
    "TRUSTSTORE_PASSWORD": "passwordfromnifi.properties",
    "TRUSTSTORE_TYPE": "JKS",
    "INITIAL_ADMIN_IDENTITY": "CN=sys_admin, OU=NIFI"
  },
  "networks": [
    {
      "mode": "container/bridge"
    }
  ],
  "acceptedResourceRoles": ["slave_public"],
  "instances": 1,
  "cpus": 1,
  "mem": 5120
}