class Companion::Manager
- Companion::Manager
- Reference
- Object
Overview
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.
Defined in:
events.crmanager.cr
Constant Summary
-
Log =
Companion::Log.for(self)
Constructors
-
.new(docker : Docker::Client)
Create an new Manager.
Instance Method Summary
-
#add_project(name : String, content : String, working_directory : Path | Nil = nil)
Add a new project.
-
#check_updates(&block : UpdateEvent -> ) : Nil
Checks if there are images update.
-
#create(name : String) : Nil
Creates missing containers for the project name.
- #create_container(project_name : String, service : Companion::Docker::Compose::Service) : String
-
#down(name : String) : Nil
Kills and removes all containers for the project name.
-
#down(name : String, &block : String -> ) : Nil
Kills and removes all containers for the project name.
-
#down_service(project_name : String, service_name : String) : Nil
Kills and removes the service service_name container for the project project_name.
-
#each_projects
Returns an iterator over the projects' names.
-
#get_logs(project_name : String, name : String) : String
Returns a project container's logs
- #images : Hash(String, Companion::Manager::ImageState)
- #networks : Array(Companion::Docker::Client::Network)
-
#pull_image(image : String) : Nil
Pull an image.
-
#pull_images(name : String) : Nil
Pulls the docker images for the project name.
-
#start(name : String)
Starts all the containers for the project name.
-
#up(name : String)
Creates and starts containers for the project name.
-
#up_service(project_name : String, service_name : String) : Nil
Creates and starts the service service_name container for project project_name.
Constructor Detail
Instance Method Detail
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.
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.
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.
Kills and removes all containers for the project name.
Yield each service name.
Kills and removes the service service_name container for the project project_name.
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".
Starts all the containers for the project name.
If a container is already running, it does nothing.
Creates and starts the service service_name container for project project_name.
It does not pull the image.