Skip to content

Copy is deprecated, what to use instead? #699

Answered by electrovir
electrovir asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like the solution is to use the tar package from npm in conjunction with this package's Container.putArchive method. Like this:

import * as tar from 'tar';
import Docker from 'dockerode';
import {readdir} from 'fs/promises';

const docker = new Docker();
const container = docker.getContainer('container-name-here');

await tar.c(
    {gzip: true, file: 'tar-file-name-here.tar', cwd: 'dir-of-files-to-copy'},
    await readdir('dir-of-files-to-copy'),
);
await container.putArchive('tar-file-name-here.tar', {path: 'container-path-to-copy-to-here'});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by electrovir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant