> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
