With your container running, you can now connect to it for the first time. If everything works as expected, you should see the following: Create your first connection The -e switch adds an environment variable called POSTGRES_PASSWORD with a value of “development” and the container will be based on the postgres:14 image. This command will run a new container called my_database with port ( -p) 5432 in the container mapped to port 5432 on the host machine. To spin up your first Postgres container, you can run the command: docker run -name my_database -p 5432:5432 -e POSTGRES_PASSWORD=development postgres:14 With that all figured out, you will use postgres:14 as your base image for the rest of the tutorial. To keep the development environment as close to production as possible, let’s use version 14 locally as well. However, if you look at cloud providers such as AWS or GCP, they currently support up to version 14. Postgres is currently supported up to version 15 using official images. While there are others you can use, we always recommend sticking with official images as they tend to be the best supported. The first step is to find the image you want to use as the base of your container. Pick an image for your Postgres container Let’s look at how you can use Docker to help solve these issues.īefore we get started, you will need to have Docker installed on your machine and a free Architect account. This is where Docker containers come in.īy using a Docker container, you can achieve more fine-grained control over how Postgres is used in your development environment. Installing Postgres directly on your machine can make these situations difficult to deal with. Complex integration testing issues when previous tests are not cleaned up properly.Getting into a bad state due to conflicting local applications.Needing access to two different versions of Postgres simultaneously.Some common scenarios that can lead to a loss in development time are: While cloud providers like AWS make it easy to get running in production with RDS, the local development experience can be left somewhat lacking. Whether you need to store information generated by users or a list of items you are looking to sell, Postgres is one of the most popular choices by software engineers. PostgreSQL is an open-source, relational database that can store all the dynamic information required for your application to operate.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |