View Source DockerCompose (DockerCompose Elixir v1.0.0)

Docker Compose CLI

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

Summary

Functions

docker-compose down

docker-compose restart

docker-compose start

docker-compose stop

docker-compose up

Types

@type exit_code() :: non_neg_integer()
@type output() :: Collectable.t()

Functions

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

docker-compose down

Options

  • 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
  • compatibility: true - if true, runs compose in backward compatibility mode

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
@spec restart(Keyword.t()) :: {:ok, output()} | {:error, exit_code(), output()}

docker-compose restart

Options

  • 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.
  • compatibility: true - if true, runs compose in backward compatibility mode
@spec 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

  • 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.
@spec stop(Keyword.t()) :: {:ok, output()} | {:error, exit_code(), output()}

docker-compose stop

Options

  • 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.
  • compatibility: true - if true, runs compose in backward compatibility mode
@spec 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

  • 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.
  • compatibility: true - if true, runs compose in backward compatibility mode
  • quiet_pull: true - if true, pull without printing progress information