2017 © Pedro Peláez
 

library docker

A PHP Library for the Docker Engine API

image

khs1994/docker

A PHP Library for the Docker Engine API

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 26 % Grown

The README.md

Docker PHP SDK

GitHub stars PHP from Packagist GitHub (pre-)release Build Status StyleCI codecov , (*1)

A PHP library for the Docker Engine API, (*2)

微信订阅号

, (*3)

关注项目作者微信订阅号,接收项目最新动态, (*4)

Installation

To Use Docker PHP Library, simply:, (*5)

$ composer require khs1994/docker

For latest commit version:, (*6)

$ composer require khs1994/docker @dev

Usage

<?php

require __DIR__.'/vendor/autoload.php';

use Docker\Docker;

$option = Docker::createOptionArray('127.0.0.1:2375');

// Connect TLS Docker Daemon

// $option = Docker::createOptionArray('123.123.123.133:2376',true,'/etc/docker/cert');

$docker = Docker::docker($option);

$docker_container = $docker->container;

$docker_image = $docker->image;

/*
 * $ docker run -it -d -v lnmp-data:/app php:7.2.8-fpm-alpine3.7 /bin/sh
 */

$image = 'php:7.2.8-fpm-alpine3.7';

$docker_image->pull($image);

$container_id = $docker_container
  ->setImage($image)
  ->setCmd(['/bin/sh'])
  ->setBinds(['lnmp-data:/app'])
  ->create(true);

$docker_container->start($container_id);

var_dump($docker_container->logs($container_id));

Laravel

$ php artisan vendor:publish --tag=config

Then edit config file config/docker.php, (*7)

use Docker;

// call by facade
Docker::container()->list();

// call by helper function
docker()->container()->list();

// call by DI

class MyController
{
    public $docker;

    public function __construct(\Docker\Docker $docker)
    {
        $this->docker = $docker;
    }

    public function demo()
    {
        $this->docker->container()->list();
    }
}

Who use it?

PHP CaaS

Powered By khs1994-docker/lnmp, (*8)

The Versions

24/07 2018

dev-master

9999999-dev https://github.com/khs1994-docker/libdocker

A PHP Library for the Docker Engine API

  Sources   Download

MIT

The Requires

 

The Development Requires

api sdk

10/05 2018

dev-analysis-8b2e9l

dev-analysis-8b2e9l https://github.com/khs1994-docker/libdocker

A PHP library for the Docker Engine API

  Sources   Download

MIT

The Requires

 

The Development Requires

api sdk