<p>The service name, in this case <code>postresql</code>, represents the name of the host for other Docker containers to address.  By switching the service name to <code>foo</code> you now have a container that can be addressed with that hostname.</p>
<p>by default <code>phppgadmin</code> looks for Postgresql to be running on a host named <code>postsgresql</code>, you can change this by passing the <code>DATABASE_HOST</code> environment variable to the <code>phppgadmin</code> container.</p>
<pre class="lang-yaml prettyprint-override"><code>phppgadmin:
  image: docker.io/bitnami/phppgadmin:7
  ports:
    - '80:8080'
    - '443:8443'
  environment:
    - DATABASE_HOST=foo  
  depends_on:
    - foo
</code></pre>

CC BY-SA 4.0
2021-10-28T17:11:53.490Z
2021-10-28T17:36:26.680Z
2021-10-28T17:36:26.680Z
swysocki
<p>I'm new to docker-compose but my intuition is that it should not matter at all how a service is named, like a variable in a programming language. Is that correct and is there some obscure bug or is there some magic in the background that I don't understand?</p>
<p>The following <a href="https://github.com/bitnami/bitnami-docker-phppgadmin/blob/master/docker-compose.yml" rel="nofollow noreferrer">example from the bitnami phppgadmin repository</a> only works if the service is named exactly &quot;postgresql&quot;:</p>
<pre class="lang-yaml prettyprint-override"><code>version: '2'
services:
  postgresql:
    image: docker.io/bitnami/postgresql:11
    environment:
      - POSTGRESQL_PASSWORD=bitnami
    volumes:
      - 'postgresql_data:/bitnami'
  phppgadmin:
    image: docker.io/bitnami/phppgadmin:7
    ports:
      - '80:8080'
      - '443:8443'
    depends_on:
      - postgresql
volumes:
  postgresql_data:
    driver: local
</code></pre>
<p>As soon as I rename the service to anything else, it breaks with a &quot;login failed&quot; in the phppgadmin interface with no further information neither on the page nor in the docker compose logs:</p>
<pre class="lang-yaml prettyprint-override"><code>version: '2'
services:
  foo:
    image: docker.io/bitnami/postgresql:11
    environment:
      - POSTGRESQL_PASSWORD=bitnami
    volumes:
      - 'postgresql_data:/bitnami'
  phppgadmin:
    image: docker.io/bitnami/phppgadmin:7
    ports:
      - '80:8080'
      - '443:8443'
    depends_on:
      - foo
volumes:
  postgresql_data:
    driver: local
</code></pre>
<p>I am using <code>docker-compose down</code> and then <code>docker-compose up</code> to make sure there is no leftover container from a previous run.</p>

CC BY-SA 4.0
2021-10-30T07:55:50.520Z
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Community
<docker-compose>
Error when renaming docker-compose service
Konrad Höffner
# Error when renaming docker-compose service

(Asked by: username_0 on 2021-10-28)

I'm new to docker-compose but my intuition is that it should not matter at all how a service is named, like a variable in a programming language. Is that correct and is there some obscure bug or is there some magic in the background that I don't understand?
The following example from the bitnami phppgadmin repository only works if the service is named exactly "postgresql":
version: '2'
services:
  postgresql:
    image: docker.io/bitnami/postgresql:11
    environment:
      - POSTGRESQL_PASSWORD=bitnami
    volumes:
      - 'postgresql_data:/bitnami'
  phppgadmin:
    image: docker.io/bitnami/phppgadmin:7
    ports:
      - '80:8080'
      - '443:8443'
    depends_on:
      - postgresql
volumes:
  postgresql_data:
    driver: local

As soon as I rename the service to anything else, it breaks with a "login failed" in the phppgadmin interface with no further information neither on the page nor in the docker compose logs:
version: '2'
services:
  foo:
    image: docker.io/bitnami/postgresql:11
    environment:
      - POSTGRESQL_PASSWORD=bitnami
    volumes:
      - 'postgresql_data:/bitnami'
  phppgadmin:
    image: docker.io/bitnami/phppgadmin:7
    ports:
      - '80:8080'
      - '443:8443'
    depends_on:
      - foo
volumes:
  postgresql_data:
    driver: local

I am using docker-compose down and then docker-compose up to make sure there is no leftover container from a previous run.

**Tags:** docker-compose

> **Comments:**
> **username_1**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  

---

## 1 answers

### Answer by username_2 on 2021-10-28. Score: 1 | Accepted answer

The service name, in this case postresql, represents the name of the host for other Docker containers to address.  By switching the service name to foo you now have a container that can be addressed with that hostname.
by default phppgadmin looks for Postgresql to be running on a host named postsgresql, you can change this by passing the DATABASE_HOST environment variable to the phppgadmin container.
phppgadmin:
  image: docker.io/bitnami/phppgadmin:7
  ports:
    - '80:8080'
    - '443:8443'
  environment:
    - DATABASE_HOST=foo  
  depends_on:
    - foo


---

