[DevOps] Set up and run a PostgreSQL instance locally with Docker Compose
2023-09-14 09:00:47 时间
When we need to spin up a database instance for our new project, installing the database management system directly on our local machine is almost always a bad idea. Luckily, Docker is here to help us practically reduce the complexity of dealing with "missing dependencies" and weird error messages down to zero.
In this lesson, we will learn how to get a PostgreSQL instance running locally with Docker Compose, so we can work on the database integration of our project and test things out with ease. To follow this lesson, you will need to have Docker pre-installed.
docker-compose.yml:
version: "3.8" services: db: image: "postgres:12" ports: - "54320:5432" volumes: - ./pgdata:/var/lib/postgresql/data environment: - POSTGRES_USER=alice - POSTGRES_PASSWORD=wonderland - POSTGRES_DB=myawesomedb
# Up and Running docker-compose -d # Check Whether contain is running docker-compose ps # enter the shell docker-compose run db bash ## Verify db exist poql --host=db --username=alice --dbname=myawesomedb ## Esc the db Ctrl + d twice # Off docker-compose down
相关文章
- 【华为云技术分享】云图说 | ContainerOps推出灰度发布模式,助力企业落地容器DevOps最佳实践
- 【华为云实战开发】16.DevOps交付模式下的软件测试
- DevOps - 应用程序的十二因子
- [DevOps] Environment Variables with Travis
- DevOps - Groovy
- DevOps - DevOps精要 - 落地
- DevOps - 云原生(Cloud Native)
- [DevOps] CI/CD Benefits
- DevOps 是扯淡:是时候埋葬 DevOps 了!
- Docker DevOps实战: 一分钟搭建Hexo博客
- 2021年中国DevOps现状调查报告发布!
- 【华为大咖分享】10.DevOps敏捷测试之道(后附PPT下载地址)
- 猿创征文 | DevOps运维的10个日常使用工具分享
- 【2023】DevOps、SRE、运维开发面试宝典之Docker相关面试题
- 云原生DevOps篇:使用Pipeline流水线项目构建Docker镜像实战