From 127b038bb939e57d6c47ea256e7528402b4b6807 Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Mon, 26 Jan 2015 21:28:23 +0100 Subject: [PATCH 1/2] Docs: Improve installation, add image pull, small changes --- docs/basic.md | 49 ++++++++++++++++++++++++++++++++++++++++++-- docs/image/pull.md | 11 ++++++++++ docs/index.md | 8 ++++---- docs/installation.md | 5 +++++ 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/docs/basic.md b/docs/basic.md index ba670ff5..41ce865b 100644 --- a/docs/basic.md +++ b/docs/basic.md @@ -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`: @@ -14,4 +14,49 @@ $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. \ No newline at end of file +`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 + +``` + +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(); + } +} + +``` \ No newline at end of file diff --git a/docs/image/pull.md b/docs/image/pull.md index 19936e00..7a965ce0 100644 --- a/docs/image/pull.md +++ b/docs/image/pull.md @@ -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'); + +``` \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 9e622c5a..2df80687 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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) diff --git a/docs/installation.md b/docs/installation.md index 087da18b..c43e9042 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -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": { @@ -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. From 2904b2d45897938855d1edc405aee5a80f9b7231 Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Tue, 27 Jan 2015 07:45:16 +0100 Subject: [PATCH 2/2] Add boot2docker TLS enabled example config to docs --- docs/basic.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/basic.md b/docs/basic.md index 41ce865b..211d0c75 100644 --- a/docs/basic.md +++ b/docs/basic.md @@ -42,6 +42,41 @@ services: ``` +**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