apache_conf 使用rails,docker为dev和test配置postgres数据库的步骤

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf 使用rails,docker为dev和test配置postgres数据库的步骤相关的知识,希望对你有一定的参考价值。

### STEPS TO CONFIGURE POSTGRES DATABASE FOR DEV AND TEST ###
### USING RAILS, DOCKER ................................. ###

0) Check if you have postgres image from dockerhub, if not pull it
> docker images
> docker pull postgres
 
1) Find out what db container is running in docker:
> docker ps

2) Stop it
> docker stop <container-name>

3) Kill it
> docker rm <container-name>

4) Make sure no postgres service is running natively:
> service --status-all | grep postgres
> service stop postgres

5) Recreate that container using same username for 
   DEV and TEST and PROD, no password. Refer to database.yml file
> docker run --name <container-name> -p 5432:5432 -e POSTGRES_USER=<username-in-database.yml> postgres

6) Test if you can connect to DBMS by using psql command
> psql -h localhost -U <username-in-database.yml>

7) List all databases available, there should not be the database in database.yml file
=# \l

8) Create a database for DEV and TEST, respectively specified in database.yml
>  rake db:create

9) Migrate a database, ie: put table in it
> rake db:migrate

10) Run rails server based on environment, ie
> rails server -e development
or
> rails server -e test

11) Test the site through browser

以上是关于apache_conf 使用rails,docker为dev和test配置postgres数据库的步骤的主要内容,如果未能解决你的问题,请参考以下文章

如何将此查询转换为ActiveRecord(Rails 5)

apache_conf 修改后的Symfony2 .htaccess文件,可以从Apache虚拟主机设置前端控制器(有点像Rails)。

Mac的Dock栏是什么?Mac Dock栏使用技巧

apache_conf 使用.htacces强制下载

apache_conf 使用.htaccess设置密码

Dock栏消失了怎么办?快速找到Dock栏