Install pgadmin III for a linked database container in docker - postgresql

There are two running docker containers. One container containing a web application and the second is a linked postgres database.
Where should the Pgadmin III tool be installed?

pgAdmin can be deployed
in a container using the image at hub.docker.com/r/dpage/pgadmin4/
E.g. to run a TLS secured container using a shared config/storage directory in /private/var/lib/pgadmin on the host, and servers pre-loaded from /tmp/servers.json on the host:
docker pull dpage/pgadmin4
docker run -p 443:443 \
-v /private/var/lib/pgadmin:/var/lib/pgadmin \
-v /path/to/certificate.cert:/certs/server.cert \
-v /path/to/certificate.key:/certs/server.key \
-v /tmp/servers.json:/pgadmin4/servers.json \
-e 'PGADMIN\_DEFAULT\_EMAIL=user#domain.com' \
-e 'PGADMIN\_DEFAULT\_PASSWORD=SuperSecret' \
-e 'PGADMIN\_ENABLE\_TLS=True' \
-d dpage/pgadmin4

Related

Changes in container not persisted after docker commit [duplicate]

This question already has answers here:
docker postgres with initial data is not persisted over commits
(5 answers)
Closed 1 year ago.
I just create a container like:
docker run --name mypostgres \
--publish 5432:5432 \
--net=apinetwork \
-e POSTGRES_PASSWORD=pwd \
-e POSTGRES_DB=db_uso \
-d postgres
I connect in the database and create some tables and objects...
After this I commit;
docker commit mypostgres user/mypostgres
But when I create other container from this image:
docker run --name mypostgres2 \
--publish 5432:5432 \
--net=apinetwork \
-e POSTGRES_PASSWORD=mysecretpassword \
-e POSTGRES_DB=correntista \
-d user/mypostgres
I don't see my objects that I created inside!
Please help me.
It's most likely you are not seeing the changes because the volume created with the original container is not being used by the new container.
See Persist the DB Docker tutorial.
You need to explicitly create a volume, and make sure it is being used in the new container.
$ docker volume create my-pg-db
$ docker run --name mypostgres \
--publish 5432:5432 \
--net=apinetwork \
-v my-pg-db:/var/lib/postgresql/data \
-e POSTGRES_PASSWORD=pwd \
-e POSTGRES_DB=db_uso \
-d postgres
This means it may not even be necessary to make a copy of your container, if all the changes you are doing are on the DB. The volume which contains the DB is what you need to preserve!
And make sure you mount and use it whenever you want to start the container.
The reason data is not persisted is explained in this other SO question:
docker postgres with initial data is not persisted over commits
The problem is that the postgres Dockerfile declares "/var/lib/postgresql/data" as a volume. This is a just a normal directory that lives outside of the Union File System used by images. Volumes live until no containers link to them and they are explicitly deleted.
which is why you need externally managed volumes like #smac90 wrote.
Source:
https://github.com/docker-library/postgres/blob/5c0e796bb660f0ae42ae8bf084470f13417b8d63/Dockerfile-debian.template#L186

How to install multiple PG Bouncers in single servers with different pool_mode

How can we Install multiple PG bouncer with different pool mode on a single server(Ubuntu18.04)?
when I tried to second time install it says already installed?
Is there any other way to install with a different port?
You could install a container rungime (eg. docker) and run multiple containers, each containing a pgbouncer installation, eg. using this image: https://github.com/edoburu/docker-pgbouncer
First, install docker:
sudo apt install docker.io
Then, start can start as many pgbouncers as you like.
pgbouncer-1:
sudo docker run --rm -d \
-n pgbouncer-session\
-e DATABASE_URL="postgres://user:pass#postgres-host/database" \
-e POOL_MODE=session \
-p 5432:5432
edoburu/pgbouncer
pgbouncer-2
sudo docker run --rm -d \
-n pgbouncer-transaction \
-e DATABASE_URL="postgres://user:pass#postgres-host/database" \
-e POOL_MODE=transaction \
-p 5433:5432
edoburu/pgbouncer
Note that the the containers use different ports on the host (first one uses 5432, second one uses 5433).
If you have lots of configuration, you might want to use a bind-mount for the configuration files.
Also, for a steady setup, I would recommend using docker-compose instead of raw docker commands.

What is the best way to install tensorflow and mongodb in docker?

I want to create a docker container or image and have tensorflow and mongodb installed, I have seen that there are docker images for each application, but I need them to be working together, from a mongodb database I must extract the data to feed a model created in tensorflow.
Then I want to know if it is possible to have a configuration like that, since I have tried with a ubuntu container and inside it to install the applications I need, but I don't know if there is another way to do it.
Thanks.
Interesting that I find this post, and just found one solution for myself. Maybe not the one for you, BTW.
What I did is: docker pull mongo and run as daemon:
#!/bin/bash
export VOLUME='/home/user/code'
docker run -itd \
--name mongodb \
--publish 27017:27017 \
--volume ${VOLUME}:/code \
mongo
Here
the 'd' in '-itd' means running as daemon (like service, not
interactive).
The --volume may not be used.
Then docker pull tensorflow/tensorflow and run it with:
#!/bin/bash
export VOLUME='/home/user/code'
docker run \
-u 1000:1000 \
-it --rm \
--name tensorflow \
--volume ${VOLUME}:/code \
-w /code \
-e HOME=/code/tf_mongodb \
tensorflow/tensorflow bash
Here
the -u make docker bash with same ownership as host machine;
the --volume make host folder /home/user/code mapping to /code in docker;
the -w work make docker bash start from /code, which is /home/user/code in host;
the -e HOME= option sign bash $HOME folder such that later you can pip install.
Now you have bash prompt such that you can
create virtual env folder under /code (which is mapping to /home/user/code),
activate venv,
pip install pymongo,
then you can connect to mongodb you run in docker (localhost may not work, please use host IP address).

Docker container not starting when connect to postgresql external

I have docker container with redmine in it and I have postgresql-95 running on my host machine, and I want to connect my redmine container to my postgresql. I followed this step : https://github.com/sameersbn/docker-redmine, to connect my container with external postgresql.
assuming my host machine with ip 192.168.100.6, so I ran this command :
docker run --name redmine -it -d \
--publish=10083:80 \
--env='REDMINE_PORT=10083' \
--env='DB_ADAPTER=postgresql' \
--env='DB_HOST=192.168.100.6' \
--env='DB_NAME=redmine_production' \
--env='DB_USER=redmine' --env='DB_PASS=password' \
redmine-docker
The container running for 1 minute but suddenly it stopped even before it runs nginx and redmine in it. I Need help about this configuration. Thank you.

I can't access mounted volume of docker-postgres from host

I create my container like this:
docker run --name postgresql -itd --restart always \
--publish 5432:5432 \
--volume /my/local/host:/var/lib/postgresql \
sameersbn/postgresql:9.4-11
but, when I do ls on the root directory, I see something like this:
drwxrwxr-x 3 messagebus messagebus 4,0K Ιαν 10 00:44 host/
or, in other words, I cannot access the /my/local/host directory. I have no idea about the messagebus user. is that normal? if this is the case, then how could I move the database from one machine to another in the future?
Try using a data container to hold your DB data. The pattern is described in the docs and is designed to promote clean separation between run-time and data.
$ docker create -v /var/lib/postgresql --name dbdata sameersbn/postgresql:9.4-11
$ docker run --name postgresql1 -itd --restart always \
--publish 5432:5432 \
--volumes-from dbdata
sameersbn/postgresql:9.4-11
A separate data container makes backup and recovery simpler and more obvious
docker run --volumes-from dbdata -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /var/lib/postgresql
The following posting I think gives a good explanation of data containers:
https://medium.com/#ramangupta/why-docker-data-containers-are-good-589b3c6c749e#.zarkr5sxc