|
1 |
| -## Installation |
| 1 | +## How to install |
2 | 2 |
|
3 |
| -On your application package run next command: |
| 3 | +### Docker compose manager module for node.js |
4 | 4 |
|
5 | 5 | ```
|
6 |
| -$ node npm install docker-compose-manager --save |
| 6 | +npm i docker-compose-manager --save |
7 | 7 | ```
|
8 | 8 |
|
9 |
| -### You can use |
| 9 | +## Docker compose manager API |
10 | 10 |
|
11 |
| -1. ```dockerComposeUp = function(dir, options, success, error)``` |
12 |
| -2. ```dockerComposeDown = function(dir, success, error)``` |
13 |
| -3. ```dockerComposeStop = function(dir, success, error)``` |
14 |
| -4. ```dockerComposeStart = function(dir, success, error)``` |
15 |
| -5. ```dockerExec = function (container, exec_command, options, success, error)``` |
16 |
| -6. ```dockerInspectIPAddressOfContainer = function (container, options)``` |
17 |
| -7. ```dockerInspectPortOfContainer = function (container, options)``` |
| 11 | +1. [dockerComposeUp](#dockercomposeup) |
| 12 | +2. [dockerComposeDown](#dockercomposedown) |
| 13 | +3. [dockerComposeStop](#dockercomposestop) |
| 14 | +4. [dockerComposeStart](#dockercomposestart) |
| 15 | +5. [dockerExec](#dockerexec) |
| 16 | +6. [dockerInspectIPAddressOfContainer](#dockerinspectipaddressofcontainer) |
| 17 | +7. [dockerInspectPortOfContainer](#dockerinspectportofcontainer) |
18 | 18 |
|
19 |
| ->Soon more documentation. |
| 19 | +### DockerComposeUp |
| 20 | + |
| 21 | +This method receives a URI of a file and builds, (re)creates, starts, and attaches to containers for a service. |
| 22 | + |
| 23 | +#### Parameters |
| 24 | + |
| 25 | + Name | Type | Description |
| 26 | + -----|------|------------- |
| 27 | + **file** | `string` | **Required.** The file where the service is described. |
| 28 | + **options** | `[string]` | **Optional.** Docker compose up commad [options](https://docs.docker.com/compose/reference/up/). |
| 29 | + |
| 30 | +#### Example |
| 31 | + |
| 32 | +```javascript |
| 33 | +var dcManager = require('docker-compose-manager'); |
| 34 | +var file = __dirname + '/docker-compose.yaml'; |
| 35 | + |
| 36 | +dcManager.dockerComposeUp(file).then(out => { |
| 37 | + console.log(out); |
| 38 | +}, err=>{ |
| 39 | + console.error(err); |
| 40 | +}); |
| 41 | +``` |
| 42 | + |
| 43 | +### DockerComposeDown |
| 44 | + |
| 45 | +This method receives a URI of a file and stops containers, removes containers, networks, volumes, and images created by [dockerComposeUp](#dockercomposeup). |
| 46 | + |
| 47 | +#### Parameters |
| 48 | + |
| 49 | + Name | Type | Description |
| 50 | + -----|------|------------- |
| 51 | + **file** | `string` | **Required.** The file where the service is described. |
| 52 | + **options** | `[string]` | **Optional.** Docker compose down commad [options](https://docs.docker.com/compose/reference/down/). |
| 53 | + |
| 54 | +#### Example |
| 55 | + |
| 56 | +```javascript |
| 57 | +var dcManager = require('docker-compose-manager'); |
| 58 | +var file = __dirname + '/docker-compose.yaml'; |
| 59 | + |
| 60 | +dcManager.dockerComposeDown(file).then(out => { |
| 61 | + console.log(out); |
| 62 | +}, err=>{ |
| 63 | + console.error(err); |
| 64 | +}); |
| 65 | +``` |
| 66 | + |
| 67 | +### DockerComposeStop |
| 68 | + |
| 69 | +This method receives a URI of a file and stops running containers without removing them. |
| 70 | + |
| 71 | +#### Parameters |
| 72 | + |
| 73 | + Name | Type | Description |
| 74 | + -----|------|------------- |
| 75 | + **file** | `string` | **Required.** The file where the service is described. |
| 76 | + **options** | `[string]` | **Optional.** Docker compose stop commad [options](https://docs.docker.com/compose/reference/stop/). |
| 77 | + |
| 78 | +#### Example |
| 79 | + |
| 80 | +```javascript |
| 81 | +var dcManager = require('docker-compose-manager'); |
| 82 | +var file = __dirname + '/docker-compose.yaml'; |
| 83 | + |
| 84 | +dcManager.dockerComposeStop(file).then(out => { |
| 85 | + console.log(out); |
| 86 | +}, err=>{ |
| 87 | + console.error(err); |
| 88 | +}); |
| 89 | +``` |
| 90 | + |
| 91 | +### DockerComposeStart |
| 92 | + |
| 93 | +This method receives a URI of a file and sStarts existing containers for a service. |
| 94 | + |
| 95 | +#### Parameters |
| 96 | + |
| 97 | + Name | Type | Description |
| 98 | + -----|------|------------- |
| 99 | + **file** | `string` | **Required.** The file where the service is described. |
| 100 | + **options** | `[string]` | **Optional.** Docker compose start commad [options](https://docs.docker.com/compose/reference/start/). |
| 101 | + |
| 102 | +#### Example |
| 103 | + |
| 104 | +```javascript |
| 105 | +var dcManager = require('docker-compose-manager'); |
| 106 | +var file = __dirname + '/docker-compose.yaml'; |
| 107 | + |
| 108 | +dcManager.dockerComposeStart(file).then(out => { |
| 109 | + console.log(out); |
| 110 | +}, err=>{ |
| 111 | + console.error(err); |
| 112 | +}); |
| 113 | +``` |
| 114 | + |
| 115 | +### DockerExec |
| 116 | + |
| 117 | +This method receives a container name and the command will be executed inside of it, and execute `docker exec` command with insede_command given. |
| 118 | + |
| 119 | +#### Parameters |
| 120 | + |
| 121 | + Name | Type | Description |
| 122 | + -----|------|------------- |
| 123 | + **container** | `string` | **Required.** The container where the command will be executed. |
| 124 | + **exec_command** | `[string]` | **Required.** The command which will be executed. |
| 125 | + **options** | `[string]` | **Optional.** Docker exec commad [options](https://docs.docker.com/engine/reference/commandline/exec/). |
| 126 | + |
| 127 | +#### Example |
| 128 | + |
| 129 | +```javascript |
| 130 | +var dcManager = require('docker-compose-manager'), |
| 131 | + container = 'node_container_01', |
| 132 | + command = ['node', '--version']; |
| 133 | + |
| 134 | +dcManager.dockerExec(container, command).then(out => { |
| 135 | + console.log(out); |
| 136 | +}, err=>{ |
| 137 | + console.error(err); |
| 138 | +}); |
| 139 | +``` |
| 140 | + |
| 141 | +### DockerInspectIPAddressOfContainer |
| 142 | + |
| 143 | +This method receives a container and retrun a promise that resolves the ip of it. |
| 144 | + |
| 145 | +#### Parameters |
| 146 | + |
| 147 | + Name | Type | Description |
| 148 | + -----|------|------------- |
| 149 | + **container** | `string` | **Required.** The container for quering. |
| 150 | + **options** | `object` | **Optional.** This object has only one field: `options.network`. This is the network where the container is attached. |
| 151 | + |
| 152 | +#### Example |
| 153 | + |
| 154 | +```javascript |
| 155 | +var dcManager = require('docker-compose-manager'), |
| 156 | + container = 'node_container_01'; |
| 157 | + |
| 158 | +dcManager.dockerInspectIPAddressOfContainer(container,{network: "bridge"}).then(ip => { |
| 159 | + console.log(ip); |
| 160 | +}, err=>{ |
| 161 | + console.error(err); |
| 162 | +}); |
| 163 | +``` |
| 164 | + |
| 165 | +### DockerInspectPortOfContainer |
| 166 | + |
| 167 | +This method receives a container and retrun a promise that resolves the port on it will expose. |
| 168 | + |
| 169 | +#### Parameters |
| 170 | + |
| 171 | + Name | Type | Description |
| 172 | + -----|------|------------- |
| 173 | + **container** | `string` | **Required.** The container for quering. |
| 174 | + |
| 175 | +#### Example |
| 176 | + |
| 177 | +```javascript |
| 178 | +var dcManager = require('docker-compose-manager'), |
| 179 | + container = 'node_container_01'; |
| 180 | + |
| 181 | +dcManager.dockerInspectPortOfContainer(container).then(port => { |
| 182 | + console.log(port); |
| 183 | +}, err=>{ |
| 184 | + console.error(err); |
| 185 | +}); |
| 186 | +``` |
0 commit comments