N
N
NyxDeveloper2021-08-21 19:53:45
PostgreSQL
NyxDeveloper, 2021-08-21 19:53:45

How to deploy a PostgreSQL database on a local machine for development?

An urgent question, I don’t want to install a full-fledged postgres, but it’s very pleasant to work with this subd. I recently learned that you can somehow use it on a local computer without installation, but I found little useful information on the Internet. Is it really possible to do something like this, or is it necessary to install and configure a full-fledged database? I am using Ubuntu Linux axis.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Sviridov, 2021-08-21
@NyxDeveloper

Install Docker and docker-compose . Create a docker-compose.yml file with the following content (see below) and run sudo docker-compose up -d in the file's directory.

version: '2'
services:
    db:
        image: postgres:13
        volumes:
            - ./db:/var/lib/postgresql/data/pgdata
        ports:
            - 5428:5432
        environment:
            - POSTGRES_USER=user
            - POSTGRES_DB=mydatabase
            - POSTGRES_PASSWORD=12345
            - PGDATA=/var/lib/postgresql/data/pgdata

The database will be available according to the following data:
  • Host : 127.0.0.1
  • Port : 5428
  • Database name : mydatabase
  • User : user
  • Password : 12345

Ps After restarting the container, the contents of the database will not be cleared, because specified volumes .

D
Dmitry, 2021-08-21
@q2digger

Docker

S
shurshur, 2021-08-21
@shurshur

You don't have to be afraid of it. Postgresql comes from packages already minimally configured. It takes a little time to learn how to create a user and base (there are plenty of tutorials on the net), it will be much easier than fiddling with setting up a base in docker.

K
ky0, 2021-08-21
@ky0

Virtual machine with installed and normally configured package. Do not get used to crookedness, the DBMS in the container is from this opera.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question