How to avoid duplication of tables, when you run the application in a container?

Faced with the problem.
Used dB backend, under nextcloud. Spinning APP on the custom image .
Released the official image. Want to migrate. Created a new database pulled hranicu launched the official container works.

But the task to connect the official container to an existing database that worked on a custom container.
If I try to connect to the current the Docker when starting(APP) re-creates the table. And it turns out the error that they zadublirovanny.
How is it possible to connect to an existing database ? In Docker newbie.
I would appreciate any tips on what to Google for which files to examine. Thanks in advance.

June 8th 19 at 16:50
1 answer
June 8th 19 at 16:52
Described can suggest two options:
1. To create a new dB on the base off the container, run it hranicu. Then off to dump the database from the user container and deploy the new.
2. If the container writes the data into the volume, then just remount the volume in a new container without starting hranilki.
Thanks for the reply. I tried the second option to try. When people build a new container to the old directory and how it is possible to ReWire without running hranilki. - ceasar.Buckridge commented on June 8th 19 at 16:55
likely hranica called by some script added to the container. I propose to mount in this script your file (blank or existing modified). Then it will work as is written in this file. Most likely it will be or something like that. - maverick64 commented on June 8th 19 at 16:58
the container writes the data where you tell him. Of course, the database folder must be mounted external as -v

In your case I would use just the first option, moved the dB dump.
With next/owncloud there are situations where you want to use their migration tool, even when upgrading minor versions. - Willard_Jerde67 commented on June 8th 19 at 17:01
, The base is not mounted in a volyum database on a separate server.
The base connects with the container is started, the variable is passed. According to this example:
-e POSTGRES_DB=db_name \
-e POSTGRES_USER=db_user \

So when you run the container and sent to directories of informal container, the duplication of tables. I do not understand how to make it when you start creating tables, and just connect to the existing database. - ceasar.Buckridge commented on June 8th 19 at 17:04
, , The amendment does not duplicate tables of volumes and mirroring when you connect, the files are normally "prokalyvayutsya". - ceasar.Buckridge commented on June 8th 19 at 17:07
error went away with duplication, but the application does not start.
Created and deployed a dump of the dB, salustio container. Running nonstop. But the app doesn't start...
Curl shows
HTTP/1.1 500 Internal Server Error
Date: Mon, 05 Feb 2018 20:33:23 GMT
Server: Apache/2.4.10 (Debian)
X-Powered-By: PHP/7.1.9
Connection: close
Content-Type: text/plain; charset=utf-8

And the browser displays

5a78ca0d23009347570489.jpeg - ceasar.Buckridge commented on June 8th 19 at 17:10
try to make
$ docker logs <container_name></container_name> - maverick64 commented on June 8th 19 at 17:13

Find more questions by tags DockerPostgreSQLSystem administrationLinux