If this is not specified, the default username: postgres will be used. We can also customize the container by changing some of its environment variables.įor example, with the POSTGRES_USER variable, we can set the username of the superuser to login to Postgres. We can start multiple containers from 1 single image. If you’re new to docker, it’s important to distinguish 2 terms: image and container.īasically, a container is 1 instance of the application contained in the image, which is started by the docker run command. Finally the last argument is the name of the image: postgres.Then the -d flag is used to tell Docker to run this container in background (or detach mode).In this case, we can set the password to connect to Postgres. The -e flag is used to set environment variable for the container.Then we use the -name flag to specify the name of the container.We use the docker run command for this purpose. OK, so now we have the Postgres image, let’s learn how to run it to start a Postgres database server container. And look at the size of this image, it’s just around 150MB, pretty small. Now if we run docker images, we can see the postgres image right here. You can apply it to download any other images of any version you want.Īlright, the image is successfully downloaded. We use a : to separate the image name and its tag (or version). The syntax to pull an image is docker pull. Thanks to the light-weight alpine linux distribution.Įnter fullscreen mode Exit fullscreen mode I often use alpine image, since its size is very small. There are many other versions with different tags as well. This will pull the image with the latest tag. But we’re gonna use the first one, because it is the official Postgres image.Īs you can see here, we can simply run docker pull postgres to get this image. So let’s go to Docker Hub to search for its image. In this course, we will use PostgreSQL as the database engine for our app. So let’s learn how to pull the first image. If we run docker images to list all available docker images. At the moment it’s an empty list because we haven’t run any containers yet. We use docker ps command to list all running containers. When the circle turns green, we know that docker desktop is started and ready to be used. Right now it’s a yellow circle, which means docker desktop is still starting. Let's open the app! It will take a while for docker desktop to start, you can see its status by clicking on this icon. And that’s it! Docker desktop is successfully installed. On a Mac, it’s super easy! We just need to open this docker website and click download.Īfter the installer is downloaded, we open it, and drag Docker into the Applications folder. Here's the link to the full series playlist on YoutubeĪlright, let’s start by installing docker. We will also learn how to setup and use TablePlus to connect and interact with Postgres, and use it to run the SQL script that we’ve generated in the previous lecture to create our Simple Bank’s database schema. Today we will learn how to install Docker Desktop on local machine, then download and start a PostgreSQL container. In the last lecture, we’ve learn how to design a database schema with dbdiagram.io Welcome back to the backend master class! 3 How to write & run database migration in Golang 4 Generate CRUD Golang code from SQL | Compare db/sql, gorm, sqlx, sqlc 5 Write Go unit tests for db CRUD with random data 6 A clean way to implement database transaction in Golang 7 DB transaction lock & How to handle deadlock 8 How to avoid deadlock in DB transaction? Queries order matter! 9 Deeply understand Isolation levels and Read phenomena in MySQL & PostgreSQL 10 How to setup Github Actions for Go + Postgres to run automated tests 11 Implement RESTful HTTP API in Go using Gin 12 Load config from file & environment variables in Golang with Viper 13 Mock DB for testing HTTP API in Go and achieve 100% coverage 14 Implement transfer money API with a custom params validator in Go 15 Add users table with unique & foreign key constraints in PostgreSQL 16 How to handle DB errors in Golang correctly 17 How to securely store passwords? 18 How to write stronger unit tests with a custom go-mock matcher 19 Why PASETO is better than JWT for token-based authentication? 20 How to create and verify JWT & PASETO token in Golang 21 Implement login user API that returns PASETO or JWT access token in Go 1 Design DB schema and generate SQL code with dbdiagram.io 2 Install & use Docker + Postgres + TablePlus to create DB schema.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |