Timeline for Docker - How can run the psql command in the postgres container?
Current License: CC BY-SA 4.0
21 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 1, 2024 at 16:43 | comment | added | Eric Duminil |
If you define PGPASSWORD environment variable (e.g. in docker-compose.yml), you won't need to type any password.
|
|
| S Aug 27, 2021 at 8:46 | history | suggested | questionto42 | CC BY-SA 4.0 |
the last project parameter is doubled by mistake. The `-W` does not have a value after it, and in the text, it is not mentioned either. Since it also throws a warning that the last parameter is ignored, as also reported in the comments, this should be a mistake.
|
| Aug 26, 2021 at 17:50 | comment | added | questionto42 |
@KarthikRao Right, -W does not need a value after it. The first non-option parameter stands for the dbname, which is why the double project is just wrong. I am just editing this.
|
|
| Aug 26, 2021 at 13:38 | review | Suggested edits | |||
| S Aug 27, 2021 at 8:46 | |||||
| Mar 16, 2021 at 16:29 | comment | added | alex | Above command is what worked for me as well. | |
| Oct 17, 2020 at 8:10 | review | Suggested edits | |||
| Oct 18, 2020 at 7:32 | |||||
| Dec 6, 2019 at 3:32 | comment | added | Karthik Rao |
After running the above command, I was getting psql: warning: extra command-line argument "project" ignored For me this worked, docker exec -it <container_id> psql -U <username> -W <database_name>
|
|
| Sep 12, 2019 at 14:42 | comment | added | jave.web |
If its just one command, you could put it straight there as psql parameter --command="CREATE extension whatever"
|
|
| Feb 11, 2019 at 15:09 | comment | added | Sonic Soul |
i get "could not connect to server: no such file or directory" seems to be looking in /var/run/postgresql/ which does not exist
|
|
| Mar 6, 2018 at 7:05 | comment | added | kamal | How to set the hostname? | |
| Nov 28, 2017 at 2:24 | comment | added | gabe |
docker-compose exec postgres psql -U project -W project works too if you have a running container (docker-compose up postgres).
|
|
| Aug 24, 2017 at 12:32 | comment | added | Vivek Kodira |
May need to use docker exec -it yiialkalmi_postgres_1 sh -c "psql -U project -W project project" instead.
|
|
| Dec 21, 2016 at 13:50 | vote | accept | Dabagab | ||
| Nov 25, 2016 at 21:18 | comment | added | Alkis Kalogeris | @joselo I haven't done this before, but I'm confident it's not that hard. Please open a new thread posting your question. That way more people will see your question. The comments are not a good place to ask a new question. | |
| Nov 25, 2016 at 18:16 | comment | added | joselo | Hi, thanks for your answer, I'm trying to restore a database using that command but I'm not sure is is ok, any help? docker exec avm_db_1 psql -U postgres < mydatabase.back | |
| May 8, 2016 at 15:56 | comment | added | Alkis Kalogeris |
To be exact you must be getting psql: FATAL: role "root" does not exist where user that you are connecting as, to the container (root@<SOMETHING>:/#)
|
|
| May 8, 2016 at 15:50 | comment | added | Alkis Kalogeris |
No need to run /bin/bash as it is already in the path. If you run docker exec -it 40e39bd0329a bash and then when you in the container's bash shell, you execute psql -U project -W project project it should work. If you execute only psql you should get an error about role not found which is postgres' way of informing you that the default user (in this case I think it's root) doesn't exist in postgres' specified users
|
|
| May 8, 2016 at 13:39 | vote | accept | Dabagab | ||
| Dec 21, 2016 at 13:50 | |||||
| May 8, 2016 at 13:39 | comment | added | Dabagab |
Thank you very much it works. I tried with this always: docker exect it 40e39bd0329a /bin/bash and then in the container run the psql command, but it always gave me errors.
|
|
| May 8, 2016 at 13:10 | history | edited | Alkis Kalogeris | CC BY-SA 3.0 |
added 638 characters in body
|
| May 8, 2016 at 13:04 | history | answered | Alkis Kalogeris | CC BY-SA 3.0 |