soyhuce / laravel-docker
Interact with a Docker instance
Installs: 7 914
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.6
- illuminate/support: ^10.0 || ^11.0
- spatie/laravel-data: ^3.9 || ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- larastan/larastan: ^2.9.2
- mockery/mockery: ^1.4
- orchestra/testbench: ^8.0 || ^9.0
- pestphp/pest: ^2.24
README
This package allows you to communicate with a Docker instance via unix socket or API.
API mode is based on API Docker Engine
Installation
You can install the package via composer:
composer require soyhuce/laravel-docker
Utilisation
Configuration
Publish configuration file via:
php artisan vendor:publish --provider="Soyhuce\Docker\ServiceProvider"
API
To use this package with API drive, you can expose Docker on HTTP port.
For example, you can do this:
socat TCP-LISTEN:<port-number>,reuseaddr,fork UNIX-CLIENT:<path-to-unix-socket>
So, in your configuration file, you have to define your configuration file like this:
[
'driver' => 'api',
'version' => 'v1.40',
'drivers' => [
'api' => [
'url' => 'http://127.0.0.1:<port-number>',
]
],
]
You can also use the unix socket to connect to Docker :
[
'driver' => 'api',
'version' => 'v1.40',
'drivers' => [
'socket' => [
'unix_socket' => '/var/run/docker.sock',
],
],
]
Working with Docker containers
- create($imageName, $containerName) : Create a container from an image
- start($containerId) : Start a container from its name or id
- stop($containerId) : Stop a container from its name or id
- wait($containerId) : Wait a container from its name or id
- delete($containerId) : Delete a container from its name or id
Working with Docker images
- create($imageName, $tagName) : Pull an image
- all() : Retrieve all images on your Docker instance
- remove($imageName) : Remove an image from its name