> For the complete documentation index, see [llms.txt](https://docs.release.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.release.com/reference-documentation/reference-examples/adding-and-removing-services.md).

# Adding and removing services

How to add or remove services based on templates or for particular environments

The `services` stanza in either the [default environment configuration](https://github.com/releasehub-com/docs/blob/main/reference-guide/application-settings/application-template.md#default-configuration) or the [environment-specific configuration](/reference-documentation/environment-settings/environment-configuration.md) defines the services that will be deployed for your application. However you may want different services per template or by environment, for example, if you use RDS for staging and production and Postgres for your ephemeral environments. Let's take a look at two ways to add or remove services.

## Remove service from template

If the service `postgres` is included in your default environment configuration and you want to remove it from your permanent template, find the `environment_templates` section and include `remove: true`, as shown in the code sample below. If you do not use the `remove` directive, the parser will assume you just want to override parts of the service instead.

```yaml
environment_templates:
- name: ephemeral
  datasets:
  - name: release-prod
- name: permanent
  services:
  - name: 'postgres'
    remove: true
  auto_deploy: false
  hostnames:
  - frontend: frontend-staging-${domain}
  - docs: docs-staging-${domain}
  - backend: backend-staging-${domain}
  tracking_branch: maste
```

## Add service to template

Alternatively, you can choose not to include `postgres` in your default services, and only create the service in the `ephemeral` section of the template using the syntax `add: true`, as illustrated in the sample below. If you don't include the `add` directive, the parser will assume you are trying to override an aspect of an existing service and give you an error, since the service name `postgres` won't exist.

```yaml
environment_templates:
- name: ephemeral
  services:
  - name: postgres
    add: true
    image: postgres:11.4-alpine
    registry: public
    volumes:
    - type: persistent
      name: postgres
      mount_path: "/var/lib/postgresql/data"
    ports:
    - type: container_port
      port: '5432'
    storage:
      size: 100Gi
  datasets:
  - name: release-prod
- name: permanent
  auto_deploy: false
  hostnames:
  - frontend: frontend-staging-${domain}
  - docs: docs-staging-${domain}
  - backend: backend-staging-${domain}
  tracking_branch: master
```

## Manually deleting a service

You can also manually delete a service from the environment-specific configuration. In our Postgres example, the `postgres` service would appear in your default `services` section. When you create a permanent environment, you can remove `postgres` from the configuration and save it before deploying and your new environment will not include the service.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.release.com/reference-documentation/reference-examples/adding-and-removing-services.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
