Open JulienB37 opened 5 years ago
Hi @JulienB37, did you get this working? If so, can you post your code please? Did you stream input to the container's stdin?
hi, i did not find a good solution :(
And finally i use docker with chid_process to execute a docker command in interactive mode
const {execFileSync} = require('child_process')
execFileSync('docker', ['exec', '-it', 'myContainer', '/bin/bash'], {stdio: 'inherit'});
If someone has a better solution it would be nice
I ended up with a hacky solution by accessing the .connection
property of the stream returned from exec.start()
as seen in the last line below. I assume this is not the intended approach.
import { tarStream } from 'tar-stream';
// The outgoing tar compression stream
const tarCompressor = tarStream();
const syncContainer = await docker.container.create({
Binds: volumesToSync,
Cmd: ['sleep', 'infinity'],
Image: 'stemn/development-environment:latest',
});
await syncContainer.start();
// Create a tar extractor pointng at the root of the filesystem
const tarExtractorExec = await syncContainer.exec.create({
AttachStdin: true,
Cmd: ['tar', 'xf', '-'],
OpenStdin: true,
WorkingDir: '/',
});
// The receiving tar extractor stdio stream
const tarExtractor = await tarExtractorExec.start();
// Pipe the tar compression stream to the standard input of the tar extractor
tarCompressor.pipe(tarExtractor.connection);
Hi,
How can i make an exec command with the interactive mode ?? I'm looking for a way to do
docker exec -it test /bin/bash
with docker api.Thanks for helping.