Skip to content
This repository was archived by the owner on Oct 26, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 82 additions & 2 deletions docs/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Once `docker-php` is installed through composer you can start using it:

## Connecting

By default, Docker-PHP does not make any asumption on where your docker daemon is, you will need to specify the entrypoint when creating the client.
By default, Docker-PHP does not make any assumption on where your docker daemon is, you will need to specify the entrypoint when creating the client.

By default, Docker-PHP uses the `DOCKER_HOST` environment variable to connect to a running `dockerd`, if not set it will use `unix:///var/run/docker.sock`.
You can, however, connect to an arbitrary server by passing an instance of the transport entrypoint `Docker\Http\Client`:
Expand All @@ -14,4 +14,84 @@ $client = new Docker\Http\DockerClient(array(), 'tcp://127.0.0.1');
$docker = new Docker\Docker($client);
```

`DockerClient` is in fact a Guzzle Client with some default options.
`DockerClient` is in fact a Guzzle Client with some default options.


## Integration with Symfony

To integrate Docker-PHP into your Symfony Framework project we recommend creating a service in the service (dependency injection) container:

**Example configuration:** connecting to your local boot2docker machine with TLS disabled

```yml
parameters:
docker_entrypoint: 'tcp://192.168.59.103:2375'

services:
docker.client:
class: Docker\Http\DockerClient
arguments:
- []
- %docker_entrypoint%
- ~
- false
docker:
class: Docker\Docker
arguments:
- @docker.client

```

**Example configuration:** connecting to your local boot2docker machine with TLS enabled (default)

Create a combined key file first:

```sh
cd ~/.boot2docker/certs/boot2docker-vm/
cat key.pem > comb.pem
cat cert.pem >> comb.pem
cat ca.pem >> comb.pem
```


```yml
parameters:
docker_entrypoint: 'tcp://192.168.59.103:2376'
docker_cert_path: '/Users/username/.boot2docker/certs/boot2docker-vm'

services:
docker.client:
class: Docker\Http\DockerClient
arguments:
- []
- %docker_entrypoint%
-
ssl:
local_cert: '%docker_cert_path%/comb.pem'
- true
docker:
class: Docker\Docker
arguments:
- @docker.client

```


Docker-PHP is now available as `docker`. If you extend the default Controller from the Symfony FrameworkBundle you can write:

```php
use Docker\Docker;

class ...
{
public function indexAction()
{
/** @var Docker $docker */
$docker = $this->get('docker');

$imageManager = $docker->getImageManager();
$containerManager = $docker->getContainerManager();
}
}

```
11 changes: 11 additions & 0 deletions docs/image/pull.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# Pull an image

Using the [Docker client](../basic.md) you run

```php

$imageManager = $docker->getImageManager();

$ubuntuLatestImage = $imageManager->pull('ubuntu');

$php55Image = $imageManager->pull('php', '5.5');

```
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Docker-PHP

This is the documentation for [docker-php](https://github.com/stage1/docker-php) library.
This is the documentation for [docker-php](https://github.com/stage1/docker-php) library.

* [Connecting to Docker](#connecting-to-docker)
* [Running a container](#running-a-container)
* [Streaming a running container's output](#streaming-a-running-containers-output)
* [Running a container as a daemon](#running-a-container-as-a-daemon)
* [Streaming a running container's output](#streaming-a-running-containers-output)
* [Running a container as a daemon](#running-a-container-as-a-daemon)
* [Creating, starting, attaching and waiting for containers](#creating-starting-attaching-and-waiting-for-containers)
* [Mapping a container's ports](#mapping-a-containers-ports)
* [Finding and inspecting Containers](#finding-and-inspecting-containers)
* [Stopping and removing containers](#stopping-and-removing-containers)
* [The Docker\Container class](#the-dockercontainer-class)
* [Configuring exposed ports](#configuring-exposed-ports)
* [Configuring exposed ports](#configuring-exposed-ports)
5 changes: 5 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

The recommended way to install Docker PHP is of course to use [Composer](http://getcomposer.org/):

Run `composer require "stage1/docker-php":"@dev"` to add the dependency

or modify your composer.json manually:

```json
{
"require": {
Expand All @@ -10,4 +14,5 @@ The recommended way to install Docker PHP is of course to use [Composer](http://
}
```


**Note**: there is no stable version of Docker PHP yet.