Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
crew makes managing Docker a breeze.
$ npm install crew
First you need to add a reference to crew to to your application.
var crew = require('crew');
To connect to a Docker server, call the crew
function and provide the hostname as well as the port. Additionally, you need to provide a private key and a certificate for client-side authentication, and a CA certificate for server-side authentication.
You may use the environment variables DOCKER_HOST
and DOCKER_CERT_PATH
to get appropriate values.
crew({
host: url.parse(process.env.DOCKER_HOST).hostname,
port: url.parse(process.env.DOCKER_HOST).port,
keys: {
privateKey: fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'key.pem')),
certificate: fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'cert.pem')),
caCertificate: fs.readFileSync(path.join(process.env.DOCKER_CERT_PATH, 'ca.pem'))
}
}, function (err, dockWorker) {
// ...
});
To ping the Docker server, use the ping
function.
dockWorker.ping(function (err) {
// ...
});
If you need to verify whether an image is available on the Docker server, use the hasImage
function and provide the name of the image.
dockWorker.hasImage('hello-world', function (err, hasImage) {
console.log(hasImage); // => true
// ...
});
Please note that verification does not respect tags, i.e. if any version of the image is available, verification will succeed.
To download an image to the Docker server, use the download
function and provide the name of the image. If you want to download a specific version, add the tag to the name of the image.
dockWorker.download('hello-world', function (err) {
// ...
});
To create and start a container, call the start
function and provide the name of the image and the desired container name. This returns the newly created container's id.
dockWorker.start({
image: 'hello-world',
name: 'myContainer'
}, function (err, id) {
console.log(id); // => '70073a08b0f7fdfef44ca6fe03ba5e796d4773d9628b6f68eb7e34568dc73e1f'
// ...
});
To forward container ports to the host, add the ports
property to the parameter object and hand over an array of forwardings.
dockWorker.start({
image: 'hello-world',
name: 'myContainer',
ports: [
{ container: 3000, host: 80 }
]
}, function (err, id) {
// ...
});
To set environment variables, add the env
property to the parameter object and hand over the keys and values you want to use as environment variables.
dockWorker.start({
image: 'hello-world',
name: 'myContainer',
env: {
port: 3000
}
}, function (err, id) {
// ...
});
To use volumes from the host, add the volumes
property to the parameter object and hand over an array of volume mappings.
dockWorker.start({
image: 'hello-world',
name: 'myContainer',
volumes: [
{ container: '/data', host: '/home/janedoe/foo' }
]
}, function (err, id) {
// ...
});
To stop and automatically remove a running container, call the stop
function and provide the name of the container.
dockWorker.stop('myContainer', function (err) {
// ...
});
This module can be built using Grunt. Besides running the tests, this also analyses the code. To run Grunt, go to the folder where you have installed crew and run grunt
. You need to have grunt-cli installed.
$ grunt
Before running the test, you need to build the thenativeweb/crew-test
image. It is included in this repository. To build it, run the following command.
$ grunt build
The MIT License (MIT) Copyright (c) 2014 the native web.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
crew makes managing Docker a breeze.
The npm package crew receives a total of 25 weekly downloads. As such, crew popularity was classified as not popular.
We found that crew demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.