# @nomiclabs/hardhat-docker

> A library to manage Docker from Hardhat plugins

Latest version **2.0.2** (published 2021-10-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nomiclabs/hardhat-docker
pnpm add @nomiclabs/hardhat-docker
yarn add @nomiclabs/hardhat-docker
bun add @nomiclabs/hardhat-docker
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2021-10-14 |
| First published | 2020-10-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 42.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8508 |
| Author | Nomic Labs LLC |
| Maintainers | fzeoli, alcuadrado, fvictorio |
| Keywords | hardhat, docker |

## Links

- npm: https://www.npmjs.com/package/@nomiclabs/hardhat-docker
- Repository: https://github.com/nomiclabs/hardhat
- Homepage: https://github.com/nomiclabs/hardhat/tree/master/packages/hardhat-docker
- Issues: https://github.com/nomiclabs/hardhat/issues
- npm.io page: https://npm.io/package/@nomiclabs/hardhat-docker

## Dependencies (3)

- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.1
- [dockerode](https://npm.io/package/dockerode.md) ^2.5.8
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0

## Recent versions

- 2.0.2 (latest) — 2021-10-14
- 2.0.0-rc.1 (rc) — 2020-10-21
- 2.0.1 — 2021-09-09
- 2.0.0 — 2020-10-22
- 2.0.0-rc.0 — 2020-10-19

## README

[![npm](https://img.shields.io/npm/v/@nomiclabs/hardhat-docker.svg)](https://www.npmjs.com/package/@nomiclabs/hardhat-docker) [![hardhat](https://hardhat.org/buidler-plugin-badge.svg?1)](https://hardhat.org)

# `hardhat-docker`

## What

A library to manage Docker from Hardhat plugins.

## Installation

```bash
npm install @nomiclabs/hardhat-docker
```

## Usage

Importing HardhatDocker

```js
const { HardhatDocker } = require("@nomiclabs/hardhat-docker");
```

Running Docker container

```js
const image = { repository: "alpine", tag: "latest" };
const docker = await HardhatDocker.create();

if (!(await docker.hasPulledImage(image))) {
  await docker.pullImage(image);
}

const { statusCode, stdout, stderr } = await docker.runContainer(image, [
  "echo",
  "Hello world!",
]);

console.log(stdout.toString());
```

Available methods

| Method | Description | Arguments | Return Type |
| --- | --- | --- | --- |
| isInstalled | check if docker is installed |  | `Promise<boolean>` |
| imageExists | check if docker image is available on docker hub | Image | `Promise<boolean>` |
| hasPulledImage | check if docker image is pulled | Image | `Promise<boolean>` |
| isImageUpToDate | check if latest docker image is installed | Image | `Promise<boolean>` |
| pullImage | pulls docker image from docker hub | Image | `Promise<void>` |
| imageToRepoTag | returns image repository tag | Image | `String` |
| runContainer | runs docker container | Image, command | `Promise<ProcessResult>` |

---
_Source: https://npm.io/package/@nomiclabs/hardhat-docker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
