class

Companion::Manager

Inherits Reference < Object

Manage all docker operations.

Some care must be taken for updates to be detected. At startup, the images state is saved. You can then add project.

When upping a project, missing images will be pulled, but not new ones, and the images state will be refreshed.

You should then run periodically Companion::Manager#check_updates which pulls all images and yield Companion::UpdateEvent for each service that can be updated.

Constants

Log = Companion::Log.for(self)

Constructors

new(docker : Docker::Client)

Create an new Manager.

Source

Instance methods

add_project(name : String, content : String, working_directory : Path | Nil = nil)

Add a new project.

The project must have a unique name, and content must be a some YAML describing the project using docker-compose 3.8 format. working_directory must be the project's directory. It is used to find bind mounts.

Source
check_updates

Checks if there are images update.

If an update is found, the block is called with an event indicating the image name and the projects's containers concerned.

Source
create(name : String) : Nil

Creates missing containers for the project name.

It pulls the image if needed. If the container are already there, it does not recreate them even if their config changed.

Source
create_container(project_name : String, service : Companion::Docker::Compose::Service) : String
Source
down(name : String) : Nil

Kills and removes all containers for the project name.

Source
down(name : String, &block : String -> ) : Nil

Kills and removes all containers for the project name.

Yield each service name.

Source
down_service(project_name : String, service_name : String) : Nil

Kills and removes the service service_name container for the project project_name.

Source
each_projects

Returns an iterator over the projects' names.

Source
get_logs(project_name : String, name : String) : String

Returns a project container's logs

Source
images
Source
networks
Source
pull_image(image : String) : Nil

Pull an image.

The image name can contains a tag in the form "image:tag", and even a registry in the form "regitry/image:tag".

Source
pull_images(name : String) : Nil

Pulls the docker images for the project name.

Source
start(name : String)

Starts all the containers for the project name.

If a container is already running, it does nothing.

Source
up(name : String)

Creates and starts containers for the project name.

Source
up_service(project_name : String, service_name : String) : Nil

Creates and starts the service service_name container for project project_name.

It does not pull the image.

Source

Nested types