Docker Community Forums

Share and learn in the Docker community.

Linking into a postgresql container


(Massivefermion) #1

There is a project which I am trying to get running. One of its containers is a postgresql container. But when I run it(using docker-compose) I get an error which seems to be related to the database. So I thought I should get a look at the database itself from within postgresql environment inside the container. So naturally I tried to link into it using a bash container like below:

docker run --rm -it --net saleor_default --link database bash

where database is the container_name given to the database container in the docker-compose.yml file. But when the bash starts and I enter psql, the only thing I get is:

bash: psql: command not found

as if there is no postgresql installed in this container.
So what should I do?

(Junius) #2

Did you build your own postgresql container? if you are using the official image in docker hub, psql should exist.

(Massivefermion) #3

This is a project I cloned from github, and I think it uses the official image.
One of the services defined in the docker-compose.yml has postgres as its image, which I think is the official postgres image, isn’t it?

(Junius) #4

postgres would be the official image. but why you saw bash: psql: command not found? Did you enter the postgres container?

(Massivefermion) #5

At first I ran the project using “docker-compose up”. Then I linked into it with a bash container with the command below:

docker run --rm -it --net saleor_default --link database bash

I gave the container_name “database” to the postgres container in the docker-compose.yml file.
After I ran this command, I got a bash shell.