DockerCompose (DockerCompose Elixir v0.1.0) View Source

Docker Compose CLI

Uses docker-compose executable, it must be installed and working.

Link to this section Summary

Functions

docker-compose down

docker-compose restart

docker-compose start

docker-compose stop

docker-compose up

Link to this section Types

Specs

down_summary() :: %{
  stopped_containers: [String.t()],
  removed_containers: [String.t()],
  removed_networks: [String.t()],
  removed_orphan_containers: [String.t()]
}

Specs

restart_summary() :: %{restarted_containers: [String.t()]}

Specs

start_summary() :: %{restarted_services: [String.t()]}

Specs

stop_summary() :: %{stopped_services: [String.t()]}

Specs

up_summary() :: %{
  created_containers: [String.t()],
  created_networks: [String.t()],
  pulled_images: [%{service: String.t(), image: String.t()}],
  removed_orphan_containers: [String.t()]
}

Link to this section Functions

Specs

down(Keyword.t()) :: {:ok, down_summary()} | {:error, integer(), down_summary()}

docker-compose down

Options

  • compose_path: path - path to the compose if not in the standard location
  • remove_orphans: true - if true orphaned containers are removed

Result

The function returns either {:ok, summary} if the request is successful or {:error, exit_code, summary}. The exit code is the exit code of the docker-compose process that failed.

Summary is a map with

  • stopped_containers - which containers were stopped
  • removed_containers - which containers were removed
  • removed_networks - which networks were removed
  • removed_orphan_containers - which containers were removed if remove_orphans: true is specified

Specs

restart(Keyword.t()) ::
  {:ok, restart_summary()} | {:error, integer(), restart_summary()}

docker-compose restart

Options

  • compose_path: path - path to the compose if not in the standard location
  • service: name - name of the service to be restarted, can be specified multiple times to restart multiple services at once. If not specified at all then all services are restarted.

Result

The function returns either {:ok, summary} if the request is successful or {:error, exit_code, summary}. The exit code is the exit code of the docker-compose process that failed.

Summary is a map with

  • restarted_containers - which containers were restarted

Specs

start(Keyword.t()) ::
  {:ok, start_summary()} | {:error, integer(), start_summary()}

docker-compose start

Note this can only be used to start previously created and stopped services. If you want to create and start the services use up/1.

Options

  • compose_path: path - path to the compose if not in the standard location
  • service: name - name of the service to be started, can be specified multiple times to start multiple services at once. If not specified at all then all services are started.

Result

The function returns either {:ok, summary} if the request is successful or {:error, exit_code, summary}. The exit code is the exit code of the docker-compose process that failed.

Summary is a map with

  • started_services - which services were started

Specs

stop(Keyword.t()) :: {:ok, stop_summary()} | {:error, integer(), stop_summary()}

docker-compose stop

Options

  • compose_path: path - path to the compose if not in the standard location
  • service: name - name of the service to be stopped, can be specified multiple times to stop multiple services at once. If not specified at all then all services are stopped.

Result

The function returns either {:ok, summary} if the request is successful or {:error, exit_code, summary}. The exit code is the exit code of the docker-compose process that failed.

Summary is a map with

  • stopped_services - which services were stopped

Specs

up(Keyword.t()) :: {:ok, up_summary()} | {:error, integer(), up_summary()}

docker-compose up

The command is executed in detached mode, result is returned after the whole command finishes, which might take a while if the images need to be pulled.

Options

  • compose_path: path - path to the compose if not in the standard location
  • force_recreate: true - if true all specified services are forcefully recreated
  • remove_orphans: true - if true orphaned containers are removed
  • service: name - name of the service that should be started, can be specified multiple times to start multiple services. If it's not specified at all then all services are started.

Result

The function returns either {:ok, summary} if the request is successful or {:error, exit_code, summary}. The exit code is the exit code of the docker-compose process that failed.

Summary is a map with

  • created_containers - which containers were created
  • created_networks - which networks were created
  • pulled_images - which images were pulled for which services
  • removed_orphan_containers - which containers were removed if remove_orphans: true is specified