Compose file for a postgres container works on Ubuntu, not on CentOS 7: "exited with code 1"

Spent the last hour or two trying to find an answer to this one. Search has turned up nothing. It seems to be something very specific to my host. Any help trouble shooting would be very appricated.

Host is running CentOS 7.

$ docker --version
Docker version 18.06.1-ce, build e68fc7a
$ docker-compose --version
docker-compose version 1.22.0, build f46880f

I’ve turned off selinux.

I’ve tried a normal bind mount.

I’ve tried a normal bind mount prechowned to 999:999, and just left as root:root.

I’ve tried turning off firewalld. This just broke because docker couldn’t set the firewall stuff.

Running the container without using compose works. docker run --rm --name pgsqltest -v $PWD/data/database/pgsql:/var/lib/postgresql/data -e POSTGRES_PASSWORD=password -p 5432:5432 postgres:10.

The compose file works perfectly when run on my Ubuntu 18.04 laptop.

Here is what I get when I run the compose file on my CentOS 7 host (as well as the actual file):

[root@centos7host appname]# docker-compose -f docker-compose.test.yml up
Creating network "appname_default" with the default driver
Creating volume "appname_appname_pg_data" with default driver
Creating appname_postgres ... done
Attaching to appname_postgres
appname_postgres exited with code 1
[root@centos7host appname]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                          PORTS               NAMES
ae2dae8a6d4d        postgres:10         "docker-entrypoint.s…"   About a minute ago   Restarting (1) 18 seconds ago                       appname_postgres
[root@centos7host appname]# cat docker-compose.test.yml 
version: "3.2"


    file: ./secrets/dbpass

    image: postgres:10
    container_name: appname_postgres
    restart: always
      - 5432:5432
      POSTGRES_PASSWORD_FILE: /run/secrets/dbpass
      POSTGRES_USER: appname
      PGDATA: /var/lib/postgresql/data/appname
      POSTGRES_DB: appname
      - type: volume
        source: appname_pg_data
        target: /var/lib/postgresql/data
      - type: bind
        source: ./data/share
        target: /srv
    - dbpass

I received the same error when using a volume like:

- type: bind
  source: ./data/database/pgsql
  target: /var/lib/postgresql/data

instead of the appname_pg_data volume in the output above.

Any ideas?

I see that in the run command you don’t specify PGDATA, while in the docker-compose you set it to
Don’t you have an output of the docker-compose run ?
What you can do to troubleshoot is to override the entrypoint in the docker-compose, set the entrypoint to something like tail -f /etc/hosts. Once the container runs, exec into it and then execute manually the original entrypoint.