Coder Social home page Coder Social logo

docker-php's Introduction

docker-php

docker-php is a docker client writen in php. You can see it as a hack for some currently missing features in the official docker client.

Born

The primary need was to find a workaround about docker stack deploy as at the time of the creation of this project it don't support some --detach=false option (see docker/cli#373), so when it come to run end to end (e2e) tests on your ci (or your local machine) with some freshly deployed docker stack... you probably then launch your tests on a not ready stack!

Commands

There's currently only one command:

docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock ubirak/docker-php:latest stack:converge <stack>

stack converge demo

For help and more options:

docker run --rm -it ubirak/docker-php:latest stack:converge --help

NOTE: this command is also able to track that short lived services of a deployment should reach successfully their shutdown state. You have to add a docker-php.service.lifecycle=shortlived on concerned services.

Audience

docker-php is intended for people that want to hack around docker client for missing/not merged features.

Troubleshooting

Error thrown while running command "stack:converge website_designer". Message: "The command "docker stack ps website_designer --format='{{json .}}'" failed.

The service need access to your docker sock. You can run it as root -u root or change the read permission of your /var/run/docker.sock

Licensing

docker-php is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

docker-php's People

Contributors

armandabric avatar shouze avatar tyx avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

docker-php's Issues

Error during stack:converge command execution

Error thrown while running command "stack:converge --limit ' 200' fr_invoicing". Message: "Provided "-1" is not greater or equal than "0"."

Seems to be caused by one of these assertions:

Assertion::greaterOrEqualThan($desired, 0);
Assertion::greaterOrEqualThan($current, 0);

And related to this part of code that instanciate the StackProgress:

public function stackConvergeProgress(string $stackName, string $serviceCheckMethod = 'hasConverged', $filters = [], ?StackProgress $previous = null): StackProgress
{
Assertion::notBlank($stackName);
Assertion::notBlank($serviceCheckMethod);
$map = new WriteOnceHashmap();
foreach ($this->dockerClient->stackPs($stackName, $filters) as $service) {
try {
$map->add($service->getName(), \call_user_func([$service, $serviceCheckMethod]) ? 1 : 0);
if ($service->hasFailed()) {
throw DockerServiceFailure::serviceFailed($service->getName(), $service->getError());
}
} catch (\LogicException $e) {
}
}
return StackProgress::trackFromPrevious(
\array_sum(\iterator_to_array($map)),
\count($map),
$previous
);
}

Wait for service to schedule on good host

Hi,

I use docker-php for a while, and fall into a use case:
If your service failed to be schedule on a host (lack of memory for example), the task is marked as rejected, swarm reschedule service on another host, and the service finally starts

docker-php handle that by a failure
I think it should wait timeout before mark the service as failed

WDYT ?

Not usable on CI

I tried your hack on our CI but container failed with "the input device is not a TTY". I understand it would not be possible to show progress bar but it should be possible to let the container running until stack is deployed with a proper message.

docker deamon permission denied

Hey

my docker version is 18.03

when i run:

sudo docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock ubirak/docker-php:latest stack:converge bitbucket
I get:

Waiting for stack 'bitbucket' to converge

All services: to stable state

2018-04-04T06:42:58+00:00 [error] Error thrown while running command "stack:converge bitbucket". Message: "The command "docker stack ps bitbucket --format='{{json .}}'" failed.

Exit Code: 1(General error)

Working directory: /home/php/app

Output:

Error Output:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.32/tasks?filters=%7B%22label%22%3A%7B%22com.docker.stack.namespace%3Dbitbucket%22%3Atrue%7D%7D: dial unix /var/run/docker.sock: connect: permission denied
"

In ShellDockerClient.php line 32:

The command "docker stack ps bitbucket --format='{{json .}}'" failed.

Exit Code: 1(General error)

Working directory: /home/php/app

Output:

Error Output:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.32/tasks?filters=%7B%22label%22%3A%7B%22com.docker.stack.namespace%3Dbitbucket%22%3Atrue%7D%7D: dial unix /var/run/docke
r.sock: connect: permission denied

stack:converge [-l|--limit [LIMIT]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--]

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.