Skip to content
This repository was archived by the owner on Oct 26, 2019. It is now read-only.
Merged
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
34 changes: 34 additions & 0 deletions docs/cookbook/container-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,37 @@ $containerConfig->setTty(true);
```

Be aware that there is no distinction between stdout and stderr in this mode.


## Mounting a Volume

This example shows you can map your host volume `/home/myuser/myapp` to a container at `/app`

```php
$containerConfig->setVolumes(['/home/myuser/myapp' => (object) []]);

$hostConfig = new HostConfig();
// hostpath:containerpath
$hostConfig->setBinds(['/home/myuser/myapp:/app']);

$containerConfig->setHostConfig($hostConfig);
```

## Port Mapping

This example shows how you can map port 8080 on your host machine to port 80 on the container.

```php
$containerConfig->setTty(true);
$containerConfig->setExposedPorts(['80/tcp' => (object)[]]);

$portBinding = new PortBinding();
$portBinding->setHostPort('8080');
$portBinding->setHostIp('0.0.0.0');

$portMap = new \ArrayObject();
$portMap['80/tcp'] = [$portBinding];

$hostConfig = new HostConfig();
$hostConfig->setPortBindings($portMap);
```