Code Monkey home page Code Monkey logo

docker-deno's Introduction

docker_deno

A fully typed, async-first docker client library for Deno.

Installation

import Docker from "https://deno.land/x/docker_deno/mod.ts"

Add this to your deno.json file, to upgrade version just edit the version here and use the above url in your code.

{
  "imports": {
    "https://deno.land/x/docker_deno/": "https://deno.land/x/[email protected]/"
  }
}

Usage

Simple example

import Docker from "https://deno.land/x/docker_deno/mod.ts"

const docker = new Docker("/var/run/docker.sock");
const container = await docker.containers.create("my_container", {
  Image: "alpine",
  Cmd: ["ls"],
  StopTimeout: 10,
});
await docker.containers.start(container.Id);

Manipulating containers

// Fetch the list of currently running containers
const containers = await docker.containers.list({all: true});

// Create a container
const container = await docker.containers.create("my_container", {
  Image: "alpine",
  Cmd: ["echo", "hello"],
});

// Start the container
await docker.containers.start(container.Id);

// Stop a container
await docker.containers.stop(container.Id);

// Kill a container
await docker.containers.kill(container.Id, "SIGKILL");

// Restart a container
await docker.containers.restart(container.Id);

// Wait until the container has finished running
await docker.container.wait(container.Id);

// Delete a container
await docker.containers.rm(container.Id);

// Get Container stats: https://docs.docker.com/engine/api/v1.40/#tag/Container/operation/ContainerStats
await docker.containers.stats(container.Id)

Images

// List images 
await docker.images.list(ImageListOptions)

// Pull Image
await docker.images.pull('lthn/chain:latest');

// Create Image including pulling the image https://docs.docker.com/engine/api/v1.40/#tag/Image/operation/ImageCreate
await docker.images.create('ubuntu', {fromImage: "ubuntu", fromSrc:'', tag: 'latest', repo: '', platform: "linux/amd64", message: "test"})

API reference

Containers

Image

docker-deno's People

Contributors

snider avatar oursin avatar 6ixfalls avatar dylanwarnock avatar noxan avatar modprog avatar wolfgangvc avatar

Stargazers

 avatar Sveinung Tord Røsaker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.