Author: gourksaha
Date: Mon Jul 27 21:01:58 2015
New Revision: 1692951
URL: http://svn.apache.org/r1692951
Log:
SLIDER-916 Fix Docker related bugs - documentation update (Thomas Liu via
gourksaha)
Modified:
incubator/slider/site/trunk/content/docs/slider_specs/application_pkg_docker.md
Modified:
incubator/slider/site/trunk/content/docs/slider_specs/application_pkg_docker.md
URL:
http://svn.apache.org/viewvc/incubator/slider/site/trunk/content/docs/slider_specs/application_pkg_docker.md?rev=1692951&r1=1692950&r2=1692951&view=diff
==============================================================================
---
incubator/slider/site/trunk/content/docs/slider_specs/application_pkg_docker.md
(original)
+++
incubator/slider/site/trunk/content/docs/slider_specs/application_pkg_docker.md
Mon Jul 27 21:01:58 2015
@@ -68,96 +68,96 @@ Refer to [*What is Docker*](https://www.
Below is an example of how we can use Slider to deploy a multi-component
Dockerized application
-**appConfig.json**
-
-
- {
- "schema": "http://example.org/specification/v2.0.0",
- "metadata": { },
- "global": { },
- "components": {
- "REDIS": {
- "memcached.commandPath": "/user/local/bin/docker",
- "memcached.options": "-d -e REDIS_PASS=\"**None**\"",
- "memcached.statusCommand": "/usr/bin/docker ps",
- "memcached.inputFiles": [
- {
- "containerPath": "/tmp/input",
- "fileLocalPath": "/Users/peter/config.json"
- }
- ]
- }
- }
- }
-
-
-Please note that in this example, we are specifying a different docker command
path than the default `/usr/bin/docker` in appConfig.json. We also specify the
options that we need to include in the `docker run` command (`-d` is by default
included). This is just a demo as how to include docker run command options. We
also need to expose a port to listen on for the application. Thus, we are
specifying `site.global.listen_port` in appConfig.json and the export config in
metainfo.json below
-
-The config structure in appConfig.json(map) -> components(list) ->
component(map) -> containers(list)-> container(map) have to match the one in
metainfo.json.
-
-We are also adding a few configurations for the component *memcached* in
appConfig.json here. These configurations are runtime parameters of the
component, as opposed to being part of the Docker image definition in
metainfo.json.
-
**metainfo.json**
{
- "schemaVersion": "2.1",
- "application": {
- "name": "FAKEAPP",
+ "schemaVersion": "2.1",
+ "application": {
+ "name": "NODEJS-REDIS",
"components": [
{
- "name": "MEMCACHED",
- "type": "docker",
+ "name": "NODEJS",
+ "type": "docker",
"dockerContainers": [
{
- "name": "memcached",
- "image": "borja/memcached",
- "additionalParam": "--appendonly yes",
- "commandPath": "/usr/bin/docker",
- "statusCommand": "docker inspect ${container_id}"
+ "name": "nodejs",
+ "commandPath": "/usr/bin/docker",
+ "image": "rsahahw/centos-node-redis",
+ "ports": [{
+ "containerPort" : "8000"
+
+ }]
}
]
- },
+ },
{
- "name": "REDIS",
- "type": "docker",
+ "name": "REDIS",
+ "type": "docker",
"dockerContainers": [
- {
- "name": "redis",
- "image": "dockerhub/redis",
- "additionalParam": "--appendonly yes",
- "commandPath": "/usr/bin/docker",
- "ports": [
- {
- "containerPort": "11211",
- "hostPort":
"${conf:configuration/global/port1}"
- }
- ],
- "mounts": [
- {
- "containerMount": "/tmp/confg",
- "hostMount":
"${conf:configuration/global/app_root}/conf"
- }
- ]
- }
- ]
+ {
+ "name": "redis",
+ "commandPath": "/usr/bin/docker",
+ "image": "tutum/redis",
+ "ports": [{
+ "containerPort" : "6379",
+ "hostPort": "6379"
+
+ }]
+
+ }]
}
+
]
}
- }
+ }
-Please note, in metainfo.json (we are trying to migrate from metainfo.xml to
metainfo.json as an improvement to the packaging approach) we are adding some
new fields in the component section to support Docker based applications:
-- **type**: if specified as `docker`, Slider will start Docker containers for
the application; by default it is `process`, which means Slider will
instantiate the application as normal process as today
-- **containers/container**: the Docker image of the application, the name of
which will be specified in `image` field
-- **port, containerPort and hostPort**: the port of the container that will be
binded to the hostPort field, which will be translated into `-p
hostPort:containerPort` when starting the container with `docker run`
-- **mount, containerMount and hostMount**: the directories from the host that
will be mounted into the container, which will be translated into â-v
hostMount:containerMountâ when starting the container
-- **options**: allow users to specify any additional docker run command
options to use
-- **status_command**: the command that Slider can use to query the status of
the application component running in the container
-- Properties specified in metainfo.json can be overridden in appConfig.json:
**commandPath, options, statusCommand, inputFiles, mounts, ports**
+Metainfo.json is the specification about how your image should run. All fields
in the config file are not different than those in a non Docker application,
except for those under "dockerContainers". All fields under "dockerContainers"
are required unless specified "optional" and they described as below:
-**resources.json**
+- **name**: Name of your container. It doesn't affect how you launch your
application, but Slider will use it to identify the overriding value in
appConfig.json as shown later
+- **image**: The full name of you Docker image.
+- **additionalParam**: (optional) Additional params that need to be passed to
the command to be invoked during starting your Docker container
+- **commandPath**: The path to your docker command
+- **statusCommand**: (optional) The command you can specify to check the
health of your running application. Slider relies on the return value of the
command to judge if healthy. 0 as healthy and non-0 as unhealthy. If not
provided, Slider will execute "docker top ${CONTAINER_ID} | grep"
+- **port, containerPort and hostPort**: (optional) the port of the container
that will be binded to the hostPort field, which will be translated into `-p
hostPort:containerPort` when starting the container with `docker run`
+- **mount, containerMount and hostMount**: (optional) the directories from the
host that will be mounted into the container, which will be translated into
â-v hostMount:containerMountâ when starting the container
+- **options**: (optional) allow users to specify any additional docker run
command options to use. Those will be passed to 'docker run' command when
starting your application. If not specified, "-d" will be used
+
+Please note configs specified in metainfo.json can be overridden in
appConfig.json: **commandPath, options, statusCommand, inputFiles, mounts,
ports**
+
+**appConfig.json**
+
+ {
+ "schema": "http://example.org/specification/v2.0.0",
+ "metadata": {
+ },
+ "global": {
+ },
+ "components": {
+ "NODEJS": {
+ "nodejs.commandPath": "/user/local/bin/docker",
+ "nodejs.options":"-d -e
REDIS_HOST=${REDIS_HOST} --net=host",
+ "nodejs.statusCommand":"docker inspect
-f {{.State.Running}} ${CONTAINER_ID} | grep true"
+ },
+ "REDIS": {
+ "redis.options":"-d -e REDIS_PASS=**None**",
+ "redis.statusCommand":"docker top
${CONTAINER_ID} | grep redis-server"
+ }
+ }
+ }
+
+
+
+AppConfig.json is where you can provide overriding config value for those you
defined in metainfo.json. This may be needed when you want to provide some
runtime variance.
+
+Please note that you need to specify the container name before your config
key: "nodejs.commandPath" instead of "commandPath". This is to distinguish
different containers under the same component as defined in metainfo.json
+In this example, we are specifying a different docker command path than the
default `/usr/bin/docker` in metainfo.json and a different set of options that
we need to include in the `docker run` command.
+
+The config structure in appConfig.json(map) -> components(list) ->
component(map) -> containers(list)-> container(map) have to match the one in
metainfo.json.
+
+**resources.json**
{
"schema": "http://example.org/specification/v2.0.0",
@@ -167,12 +167,12 @@ Please note, in metainfo.json (we are tr
"slider-appmaster": { },
"REDIS": {
"yarn.role.priority": "1",
- "yarn.component.instances": "2",
+ "yarn.component.instances": "1",
"yarn.memory": "512"
},
- "MEMCACHED": {
- "yarn.role.priority": "1",
- "yarn.component.instances": "2",
+ "NODEJS": {
+ "yarn.role.priority": "2",
+ "yarn.component.instances": "1",
"yarn.memory": "512"
}
}
@@ -183,9 +183,9 @@ With the configuration files above, Slid
- For redis components, it will run:
-`docker run -d -p hostPort:containerPort -v hostMount:containerMount
-net=bridge dockerhub/redis`
+`docker run -d -e REDIS_PASS=**None** -p hostPort:containerPort -name
${CONTAINER_ID} tutum/redis`
-- For memcached components, it will run:
+- For nodejs components, it will run:
-`docker run -d borja/memcached memcached_server.sh --appendonly`
+`docker run -d -e REDIS_HOST=${REDIS_HOST} -name ${CONTAINER_ID} --net=host
rsahahw/centos-node-redis`