olzgeek.blogg.se

Pgadmin 4 connect to docker postgres 9.6
Pgadmin 4 connect to docker postgres 9.6





pgadmin 4 connect to docker postgres 9.6 pgadmin 4 connect to docker postgres 9.6

config/init.sql:/docker-entrypoint-initdb.d/init.sql Now let’s map this init.sql: version: '3' GRANT ALL PRIVILEGES ON DATABASE jira TO admin CREATE ROLE admin WITH LOGIN ENCRYPTED PASSWORD 'admin' SUPERUSER ĬREATE DATABASE jira WITH OWNER admin ENCODING 'UNICODE' LC_COLLATE 'C' LC_CTYPE 'C' TEMPLATE template0 Also, in the future we will need to use the postgres with JIRA so it would be better to use the initialization queries from Connect Postgres With JIRA. But firstly, let’s create the config folder near our docker-compose file and create the init.sql file inside it. We will map a file from our host machine to some file in the container. sql file in the /docker-entrypoint-initdb.d folder inside the container. Based on the description for postgres image on the Docker Hub we need just to put some. I want to create the database and user when my postgres is starting. To create one, I need to execute commands inside my container, or provide a script that can initialize the tables which will be executed by docker whenever the container starts. In the first case I would need to do this operation each time I clean my container volumes. We can check the state of our container using the command below: docker psīut currently we don’t have any tables in our postgres database. We will download the image in case we didn’t download it before and start the postgres. Now we can start our container using the following command: docker-compose up We defined the network with bridge driver to communicate with our host machine and join our postgres service to it.

pgadmin 4 connect to docker postgres 9.6

Because each docker image is based on some linux distributive we defined the volume where we will store our postres data.

pgadmin 4 connect to docker postgres 9.6

We can use this port inside the container to access our postgres. We could use it from the host machine to communicate with our postgres service. We described the service with name “jirapostgres”, set the container name, and chose the image for it. I will choose the easiest way and use the official one for the latest 9.6.3 postgres. We can create it or use the official image from Docker Hub. First of all, we need the postgres image. Let’s create the docker-compose file and describe our postgres service in it.







Pgadmin 4 connect to docker postgres 9.6