Unable to restore Mattermost Database

SUMMARY

Unable to restore Postgres database inside container using ansible. Ansible modules, shell commands and shell scripts via ansible can not restore db inside docker container. When executed manually from same backup it works. When commands have been run from ansible that were successful on any container, the container/s consistently restarts.

ISSUE TYPE- Bug Report
COMPONENT NAME##### ANSIBLE VERSION

CONFIGURATION

root@ansible:~# ansible-config dump --only-changed
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = [u’/etc/ansible/hosts’]
DEFAULT_LOG_PATH(/etc/ansible/ansible.cfg) = /var/log/ansible.log
DEFAULT_REMOTE_USER(/etc/ansible/ansible.cfg) = root
DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = skippy

OS / ENVIRONMENT

ubuntu 16.04

STEPS TO REPRODUCE

Backup and restore database using ansible on latest version of mattermost (v5 +)

As far as I can see, as long as the format is : Ansible > remote host > docker container > Postgres CLI
any commands that successfully execute inside the Postgres CLI cause the container to enter a restart loop rendering restores useless and uncheckable.


EXPECTED RESULTS

Database restores, container starts, mattermost works, can log in etc

have tried:
pg_restore
psql < (-U, -h, -c etc…)
cat the db and pipe into container
docker_container ansible module with command option

command strings, various shell scripts, piping commands into docker exec etc

ACTUAL RESULTS

Summary

Steps to reproduce

backup and restore database using ansible on latest version of mattermost (v5 +)

As far as I can see, as long as the format is : Ansible > remote host > docker container > Postgres CLI
any commands that successfully execute inside the Postgres CLI cause the container to enter a restart loop rendering restores useless and uncheckable.

Using latest version of mattermost (docker)
Ansible V 2.5.2

Expected behavior

Database restores, container starts, mattermost works, can log in etc

have tried:
pg_restore
psql < (-U, -h, -c etc…)
cat the db and pipe into container
docker_container ansible module with command option

command strings, various shell scripts, piping commands into docker exec etc

Observed behavior (that appears unintentional)