# Error on initializing postgres-postgis image

**URL:** <https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882>\
**Category:** Bug Reports\
**Tags:** docker\
**Created:** [June 10, 2018, 8:48am UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882 "2018-06-10T08:48:50Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![m2wasabi](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/m2wasabi/32/12656_2.png) [@m2wasabi](https://discuss.circleci.com/u/m2wasabi)\
**Post date:** [June 10, 2018, 8:48am UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/1 "2018-06-10T08:48:50Z")

</div>

When initializing docker image `circleci/postgres:9-alpine-postgis` , I got an error and not work.

```
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/postgis.sh
/docker-entrypoint-initdb.d/postgis.sh: line 10: syntax error: bad substitution
LOG: received SIGHUP, reloading configuration files
LOG: parameter "listen_addresses" cannot be changed without restarting the server
LOG: configuration file "/var/lib/postgresql/data/postgresql.conf" contains errors; unaffected changes were applied

Exited with code 2
```

---

<div class="post-metadata">

**Author:** ![dlancer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dlancer/32/12657_2.png) [@dlancer](https://discuss.circleci.com/u/dlancer)\
**Post date:** [June 10, 2018, 9:33am UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/2 "2018-06-10T09:33:50Z")

</div>

The same problem with `circleci/postgres:9.6-postgis`

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 10, 2018, 10:09am UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/3 "2018-06-10T10:09:54Z")

</div>

@m2wasabi, @dlancer:

Readers would need to see how you are creating this container. What do you have in your `docker` key in your YAML config? I wonder if you are using a `command` and it is causing a problem with the entrypoint.

---

<div class="post-metadata">

**Author:** ![m2wasabi](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/m2wasabi/32/12656_2.png) [@m2wasabi](https://discuss.circleci.com/u/m2wasabi)\
**Post date:** [June 10, 2018, 10:27am UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/4 "2018-06-10T10:27:02Z")

</div>

This error can occur simply below command.

`docker run -it circleci/postgres:9.6.9-alpine-postgis`

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 10, 2018, 10:28am UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/5 "2018-06-10T10:28:56Z")

</div>

Right, are you not running it in CircleCI using the `docker` key?

You _can_ use `docker run` yourself, but I expect that you need to inject in some parameters, and the default entrypoint may well fall over if those params are not provided. Take a look on GitHub for the `postgis.sh` to see what it needs.

It may also just be worthwhile to see if there is some documentation on this image. I have not used it, but I imagine it might want a hostname/IP to listen on, and a default username/password of a root user?

---

<div class="post-metadata">

**Author:** ![m2wasabi](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/m2wasabi/32/12656_2.png) [@m2wasabi](https://discuss.circleci.com/u/m2wasabi)\
**Post date:** [June 10, 2018, 10:59am UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/6 "2018-06-10T10:59:19Z")

</div>

Yes, I use `docker` key in CircleCI.

I read this document and write config.  
[https://circleci.com/docs/2.0/postgres-config/](https://circleci.com/docs/2.0/postgres-config/)

My `.circleci/config.yml` tree is below

```auto
jobs:
  test:
    docker:
      - image: circleci/openjdk:8-jdk-node-browsers
        environment:
...
      - image: circleci/postgres:9-alpine-postgis
        environment:
        - POSTGRES_USER: root
        - POSTGRES_DB: circle-test_test
    steps:
...

```

Is it need to set configure `password` ?

F.Y.R. `circleci/postgres:9.6.8-alpine-postgis` works fine. I use it temporary.

---

<div class="post-metadata">

**Author:** ![dlancer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dlancer/32/12657_2.png) [@dlancer](https://discuss.circleci.com/u/dlancer)\
**Post date:** [June 10, 2018, 11:14am UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/7 "2018-06-10T11:14:38Z")

</div>

We use this in our config and it works without a problem until latest ci images update:

```auto
docker:
  - image: circleci/postgres:9.6-postgis
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password
      POSTGRES_DB: db_name

```

---

<div class="post-metadata">

**Author:** ![yardensachs](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yardensachs/32/14882_2.png) [@yardensachs](https://discuss.circleci.com/u/yardensachs)\
**Post date:** [June 10, 2018, 2:00pm UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/8 "2018-06-10T14:00:04Z")

</div>

Same here. example:

```
waiting for server to start....LOG: database system was shut down at 2018-06-10 13:53:24 UTC
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
FATAL: role "root" does not exist
 done
server started
CREATE DATABASE

CREATE ROLE

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/postgis.sh
/docker-entrypoint-initdb.d/postgis.sh: line 10: syntax error: bad substitution
LOG: received SIGHUP, reloading configuration files
LOG: parameter "listen_addresses" cannot be changed without restarting the server
LOG: configuration file "/var/lib/postgresql/data/postgresql.conf" contains errors; unaffected changes were applied

```

YAML config:

```
version: 2
jobs:
  build:
    docker:
      - image: circleci/postgres:9.6-alpine-postgis
        environment:
        - POSTGRES_USER: root
        - POSTGRES_DB: thedatabase
```

---

<div class="post-metadata">

**Author:** ![yardensachs](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yardensachs/32/14882_2.png) [@yardensachs](https://discuss.circleci.com/u/yardensachs)\
**Post date:** [June 10, 2018, 2:04pm UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/9 "2018-06-10T14:04:08Z")

</div>

Here is what the logs say when it works:

```
waiting for server to start....LOG: database system was shut down at 2018-06-09 16:16:30 UTC
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
FATAL: role "root" does not exist
 done
server started
CREATE DATABASE

CREATE ROLE

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/postgis.sh
CREATE DATABASE
UPDATE 1
Loading PostGIS extensions into template_postgis
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
Loading PostGIS extensions into thedatabase
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION

waiting for server to shut down...LOG: received fast shutdown request
.LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

LOG: database system was shut down at 2018-06-09 16:16:35 UTC
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
```

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 10, 2018, 3:02pm UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/10 "2018-06-10T15:02:22Z")

</div>

I wonder if there is a breaking change in `postgis.sh`? I expect this is on GitHub, so you could do a custom fix initially, running from your own Docker registry, and then if that works, raise a PR for CircleCI folks to merge in for the next version.

---

<div class="post-metadata">

**Author:** ![nickgsc](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/nickgsc/32/15856_2.png) [@nickgsc](https://discuss.circleci.com/u/nickgsc)\
**Post date:** [June 10, 2018, 9:49pm UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/11 "2018-06-10T21:49:45Z")

</div>

Something definitely broke between Friday and today. There was a new push of images sometime at the end of last week that introduced the problem. See also [this issue](https://github.com/circleci/circleci-images/issues/211) reported on GitHub for the images repo.

I worked around the issue in the meantime by using `10.3-postgis-ram` instead of `10-postgis-ram` (which points to 10.4) - it seems the issue only exists in the “latest” for each major version

I also opened a ticket with CircleCI since these are their convenience images

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [June 11, 2018, 3:54pm UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/12 "2018-06-11T15:54:06Z")

</div>

The is an issue with the PostGIS variant images that was caused due to an upstream change with the PostgreSQL image. A possible fix has been merged and new images should be produced soon. I’ll follow up.

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [June 11, 2018, 4:40pm UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/13 "2018-06-11T16:40:26Z")

</div>

Newer images were pushed. This issue is resolved.

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [June 11, 2018, 4:49pm UTC](https://discuss.circleci.com/t/error-on-initializing-postgres-postgis-image/22882/14 "2018-06-11T16:49:49Z")

</div>


