[bitnami/postgresql-repmgr] executing commands within the container does not work
Name and Version
bitnami/postgresql-repmgr:14
What steps will reproduce the bug?
start the standard docker-compose.yml as:
curl -sSL https://raw.githubusercontent.com/bitnami/containers/main/bitnami/pgpool/docker-compose.yml > docker-compose.yml
docker-compose up -d
log in into the postgres node by I get "could not get current user name":
docker exec -ti bitnami_orig_pg-0_1 /bin/bash
I have no name!@cdeb06c71cd0:/$ /opt/bitnami/repmgr/bin/repmgr node status
could not get current user name: Success
I have no name!@cdeb06c71cd0:/$
If I try to add the user: root attribute to the config, the container does not start.
What is the expected behavior?
The commands within the container are usable to learn, interact, monitor the SW.
What do you see instead?
The commands within the container are not usable:
I have no name!@cdeb06c71cd0:/$ psql
psql: error: local user with ID 1001 does not exist
Additional information
No response
Ok, by logging in into the container by:
docker exec -ti -u root bitnami_orig_pg-0_1 /bin/bash I'm at least root, and can create other users...
By executing the commands:
useradd -m -G root postgreschmod -R g+r /bitnami/postgresql/data/chmod -R g+x /bitnami/postgresql/data/
The /opt/bitnami/repmgr/bin/repmgr node status commands works
Hi @esanya,
Sorry for the delay. Unfortunately, this is a bug, but it is cosmetic. You can connect to the database like this:
$ docker-compose exec -- pg-0 bash
I have no name!@17ff42f5556b:/$ psql -U customuser -d customdatabase
Password for user customuser:
psql (14.6)
Type "help" for help.
customdatabase=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------------+------------+----------+-------------+-------------+---------------------------
customdatabase | customuser | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/customuser +
| | | | | customuser=CTc/customuser
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
repmgr | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(5 rows)
If you have solved the problem, please let me know. Feedback is appreciated. Thanks for your report.
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.
Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.
this issue still seems to be open and unsolved. i just deployed fresh containers and have the same issue - you cannot exec "repmgr" due to the uid 1001 being used but no system entry for that user present. a temporary workaround is, like @esanya wrote, to create such a user inside the container:
root@id1:~/active/pgtest# docker compose exec -uroot pg-1 bash
root@5e2dfd4c19b4:/# useradd -u 1001 -m -G root postgres
root@5e2dfd4c19b4:/# exit
this will let you exec repmgr like so:
root@id1:~/active/pgtest# docker compose exec pg-1 repmgr -f /opt/bitnami/repmgr/conf/repmgr.conf node status
that, or a similar, useradd should definitely be part of the Dockerfile that creates the image....... please fix :) thanks & regards, Markus
Hi,
What we currently do in the container is to enable nss_wrapper to allow this kind of operations.
. /opt/bitnami/scripts/postgresql-env.sh
. /opt/bitnami/scripts/libpostgresql.sh
postgresql_enable_nss_wrapper
With that you should be able to execute the commands without issues.
this issue definitely isn't solved. i just re-deployed stuff and am exactly in the same position as last time. as a workaround i implemented what @javsalgar wrote.. like this
file "wrapper-repmgr" - make sure to chmod +x:
#!/bin/bash
. /opt/bitnami/scripts/postgresql-env.sh
. /opt/bitnami/scripts/libpostgresql.sh
postgresql_enable_nss_wrapper
repmgr -f /opt/bitnami/repmgr/conf/repmgr.conf $*
in docker-compose.yml, for all relevant services, add the script as a file-volume:
volumes:
- ./wrapper-repmgr:/opt/bitnami/repmgr/bin/wrapper-repmgr
now you can use a "launcher script" like "repmgr_node1":
#!/bin/bash
docker compose exec node1 wrapper-repmgr $*
.. not great. would be better to have it fixed in the container - as it is clearly a bug.
Hi @mrambossek,
Thanks for your comments.
Unfortunately, this behavior is expected because the container is designed to work with any possible user ID. So it does not save the information of a specific user. For that particular use case you would need that additional configuration that my colleague mentioned because repmgr reads user information and NSS_WRAPPER solves this problem. Anyway you can always customize the image from the Dockerfile, adding the user you need in this specific case.
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.
Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.
executing a command directly does not load the nss_wrapper configuratino. try with the following command that will load the nss_wrapper configuration:
kubectl exec -it <pod-name> /opt/bitnami/scripts/postgresql-repmgr/entrypoint.sh repmgr --help
see : [bitnami/postgresql-ha] Cannot run repmgr CLI successfully #3558