Compare commits

...

4 Commits

Author SHA1 Message Date
49445d93c6 1.0.75 2019-09-21 21:57:57 +02:00
4f838837f8 fix(core): update 2019-09-21 21:57:57 +02:00
c76968bbe8 1.0.74 2019-09-20 16:29:44 +02:00
6c5e5644b1 fix(core): update 2019-09-20 16:29:43 +02:00
6 changed files with 26 additions and 11 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@mojoio/docker",
"version": "1.0.73",
"version": "1.0.75",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@mojoio/docker",
"version": "1.0.73",
"version": "1.0.75",
"description": "easy communication with docker remote api from node, TypeScript ready",
"private": false,
"main": "dist/index.js",

View File

@ -87,24 +87,22 @@ tap.test('should create a service', async () => {
Name: 'testNetwork'
});
const testSecret = await docker.DockerSecret.createSecret(testDockerHost, {
name: 'serviceSecret',
name: 'testSecret',
version: '0.0.1',
labels: {},
contentArg: '{"hi": "wow"}'
});
const testImage = await docker.DockerImage.createFromRegistry(testDockerHost, {
imageUrl: 'nginx:latest'
imageUrl: 'registry.gitlab.com/hosttoday/ht-docker-static'
});
const testService = await docker.DockerService.createService(testDockerHost, {
image: testImage,
labels: {
testlabel: 'hi'
},
labels: {},
name: 'testService',
networks: [testNetwork],
networkAlias: 'testService',
secrets: [testSecret],
ports: []
ports: ['3000:80']
});
await testService.remove();

View File

@ -137,6 +137,10 @@ export class DockerImage {
// get stuff
public async getVersion() {
if (this.Labels && this.Labels.version) {
return this.Labels.version;
} else {
return 'x.x.x';
}
}
}

View File

@ -90,4 +90,17 @@ export class DockerNetwork {
public async remove() {
const response = await this.dockerHost.request('DELETE', `/networks/${this.Id}`);
}
public async getContainersOnNetwork(): Promise<{
[key: string]: {
Name: string;
EndpointID: string;
MacAddress: string;
IPv4Address: string;
IPv6Address: string;
};
}> {
const response = await this.dockerHost.request('GET', `/networks/${this.Id}`);
return response.body.Containers;
}
}

View File

@ -92,8 +92,8 @@ export class DockerService {
const containerPort = portArray[1];
ports.push({
Protocol: 'tcp',
PublishedPort: parseInt(containerPort, 10),
TargetPort: parseInt(hostPort, 10)
PublishedPort: parseInt(hostPort, 10),
TargetPort: parseInt(containerPort, 10)
});
}