oursin / denocker Goto Github PK
View Code? Open in Web Editor NEWA Docker client library for Deno
License: ISC License
A Docker client library for Deno
License: ISC License
In denoland/deno#8050 (issue 7326, the flag --isolatedModules
was integrated.
This causes the following error when running denocker without supplying a tsconfig
reversing that change:
error: TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
ListContainer,
~~~~~~~~~~~~~
at https://deno.land/x/[email protected]/types.ts:211:3
TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
Port,
~~~~
at https://deno.land/x/[email protected]/types.ts:212:3
Found 2 errors.
The workaround is the creating a tsconfig
:
{
"compilerOptions": {
"importsNotUsedAsValues": "remove",
"isolatedModules": false
}
}
But this should be fixed to make denocker compatible with the default settings of deno.
I'm trying to use this on MacOS (10.14.6) and the following code logs an empty array:
// index.ts
import Docker from "https://github.com/Oursin/denocker/raw/main/index.ts";
const docker = new Docker("/var/run/docker.sock");
const containers = await docker.containers.list({ all: true });
console.log(containers);
# terminal
$ deno run --unstable --allow-all index.ts
> []
Strangely, creating a container using the following works as expected :
const container = await docker.containers.create("my_container", {
Image: "alpine",
Cmd: ["ls"],
StopTimeout: 10,
});
Note: I'm currently using main
to work around #2
Can you please add the docker build method to the library?
Looks like that could be a good library, some documentation would be nice.
Hello, for begin thanks a lot for your project.
I have an issue when I try to use it for create a container.
The container.ID is always "undefined".
Source :
import Docker from "https://deno.land/x/denocker/index.ts"
console.log("Docker socket")
const docker = new Docker("/var/run/docker.sock");
console.log("Docker create")
const container = await docker.containers.create("my_container", {
Image: "alpine",
Cmd: ["ls"],
});
console.log("Container Id : "+container.Id)
Result :
Download https://deno.land/x/denocker/index.ts
Warning Implicitly using latest version (v0.2.0) for https://deno.land/x/denocker/index.ts
Download https://deno.land/x/[email protected]/index.ts
Download https://deno.land/x/[email protected]/client/auth.ts
Download https://deno.land/x/[email protected]/container.ts
Download https://deno.land/x/[email protected]/client/client.ts
Download https://deno.land/x/[email protected]/types.ts
Download https://deno.land/x/[email protected]/client/httpClient.ts
Download https://deno.land/x/base64/mod.ts
Warning Implicitly using latest version (v0.2.1) for https://deno.land/x/base64/mod.ts
Download https://deno.land/x/[email protected]/mod.ts
Download https://deno.land/x/[email protected]/base.ts
Check file:///core/main.ts
Docker socket
Docker create
Container Id : undefined
Thanks a lot !
Utilize some sort of event listener to get real-time updates from Docker. If something happens to a container outside of my Deno app, I would like to know about it.
https://docs.docker.com/engine/api/v1.37/#tag/System/operation/SystemEvents
In one terminal:
docker run --rm -ti ubuntu sleep 30
Then run this script:
import Docker from "https://deno.land/x/denocker/index.ts"
const docker = new Docker("/var/run/docker.sock");
const containers = await docker.containers.list({all: false})
console.log('containers', containers);
deno run -A --unstable dockerode-test.ts
returns:
containers []
However, changing docker.containers.list({all: false})
to docker.containers.list({all: true})
causes the process to hang indefinitely.
Do I have too many not-running containers?
docker ps -a | wc -l
returns 33
so no, not that many.
OS: macos 12.6
Docker: version 20.10.21, build baeda1f
Deno: 1.29.1 (release, x86_64-apple-darwin)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.