Push tar images into Docker registry from NodeJS without using the Docker Engine.
MIT License
With this library you can push tar Docker images directly to a Docker registry without the need of having them loaded into the Docker Engine, re-tagging and pushing.
The library uses chunked upload to push the layers.
Supports HTTP Basic auth.
First, you have to create a configuration object with the following properties:
After a successful upload, the library will take care about cleaning up the temporary files that have been created during the process. However, you might want to call this clean-up function on in one of your shutdown hooks in order to remove any leftovers in case of a shutdown.
import {DockerTarPusher, DockerTarPusherOptions} from 'docker-tar-pusher';
const options: DockerTarPusherOptions = {
registryUrl: 'http://localhost:5000',
tarball: 'path/to/file.tar'
};
const dockerTarPusher = new DockerTarPusher(options);
await dockerTarPusher.pushToRegistry();
import {DockerTarPusher, DockerTarPusherOptions, Logger} from 'docker-tar-pusher';
const myLogger: Logger = {
error: (msg: string): void => {
console.log(`[ERROR] ${msg}`);
},
warn: (msg: string): void => {
console.log(`[WARN] ${msg}`);
},
info: (msg: string): void => {
console.log(`[INFO] ${msg}`);
},
debug: (msg: string): void => {
console.log(`[DEBUG] ${msg}`);
}
};
const options: DockerTarPusherOptions = {
registryUrl: 'http://localhost:5000',
tarball: 'path/to/file.tar',
chunkSize: 8 * 1024 * 1024,
applicationLogger: myLogger,
sslVerify: false,
auth: {
username: 'testuser',
password: 'testpassword'
}
};
const dockerTarPusher = new DockerTarPusher(options);
// Attaching clean-up logic to shutdown hook
process.on('SIGINT', () => {
dockerTarPusher.cleanUp();
});
(async () => {
await dockerTarPusher.pushToRegistry();
})();
Inspired by dockerregistrypusher