DockerCompose (DockerCompose Elixir v0.3.1) 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

exit_code() :: non_neg_integer()

Specs

output() :: Collectable.t()

Link to this section Functions

Specs

down(Keyword.t()) :: {:ok, output()} | {:error, exit_code(), output()}

docker-compose down

Options

  • always_yes: true - answer "yes" to all interactive questions
  • compose_path: path - path to the compose if not in the standard location
  • project_name: name - compose project name
  • 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, output()} | {:error, exit_code(), output()}

docker-compose restart

Options

  • always_yes: true - answer "yes" to all interactive questions
  • compose_path: path - path to the compose if not in the standard location
  • project_name: name - compose project name
  • 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.

Specs

start(Keyword.t()) :: {:ok, output()} | {:error, exit_code(), output()}

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

  • always_yes: true - answer "yes" to all interactive questions
  • compose_path: path - path to the compose if not in the standard location
  • project_name: name - compose project name
  • 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.

Specs

stop(Keyword.t()) :: {:ok, output()} | {:error, exit_code(), output()}

docker-compose stop

Options

  • always_yes: true - answer "yes" to all interactive questions
  • compose_path: path - path to the compose if not in the standard location
  • project_name: name - compose project name
  • 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.

Specs

up(Keyword.t()) :: {:ok, output()} | {:error, exit_code(), output()}

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

  • always_yes: true - answer "yes" to all interactive questions
  • compose_path: path - path to the compose if not in the standard location
  • project_name: name - compose project name
  • 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.