sexta-feira, 2 de junho de 2017

DOCKER Faq, HowTo, Referece, Sample Install Run PostgreSQL in a Docker

1. Introduction

This post gathers information about PostgreSQL and Docker.


2. Step-by-Step


2.1. Ensure Docker, Docker Compose are working

# docker --version
Docker version 17.03.1-ce, build c6d412e
# docker-compose --version
docker-compose version 1.11.2, build dfed245

2.2. Install a PostgreSQL Docker

  • Determining PostgreSQL Docker Version to install

# psql --version
psql (PostgreSQL) 9.6.3


  • Pull docker image versions

# docker pull postgres:9.6.3-alpine
# docker pull postgres:9.6.3


  • Run PostgreSQL Docker Image in background - database instance

# docker run --name postgres-01 -e POSTGRES_PASSWORD=mysecretpassword -d postgres:9.6.3-alpine
# docker run --name postgres-02 -e POSTGRES_PASSWORD=mysecretpassword -d postgres:9.6.3


  • Check both Docker process images running 

# docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS               NAMES
676278f9f054        postgres:9.6.3          "docker-entrypoint..."   7 seconds ago       Up 7 seconds        5432/tcp            postgres-02
0d93213e347e        postgres:9.6.3-alpine   "docker-entrypoint..."   12 seconds ago      Up 11 seconds       5432/tcp            postgres-01


  • Stop Docker instance "postgres-02"

# docker stop postgres-02
# docker kill postgres-02


  • Run PostgreSQL psql command line, linked to running instance "postgres-01", using interative mode. Interate with application saying the password "mysecretpassword"

# docker run --name postgres-psql-01 -it --rm --link postgres-01:postgres postgres psql -h postgres-01 -U postgres:9.6.3-alpine
Password for user postgres: mysecretpassword
psql (9.6.3)
Type "help" for help.

postgres=# select current_date;
    date
------------
 2017-06-03

(1 row)

postgres=# \q



  • Run PostgreSQL plsql command line, linked to running instance "postgres-01", using interative mode, using password in command line





3. References



RAILS Faq, HowTo, Reference, Sample Setup a Rails App With Apache and Passenger on CentOS 6

1. Introduction


This post gathers information about how to setup RAILS APP with Apache and Passenger on CentOS 6.


2. Step-by-Steyp


  • Step#1: First of all, mantain your linux so up-to-date

# yum update



  • Step#2: Install Apache
# yum install httpd


  • Step#3: Install apache

# yum install httpd curl-devel httpd-devel



  • Step#4:  Get Apache to start on boot:

# chkconfig httpd on



  • Step#5: Install Phusion Passenger and dependency packages

# gem install passenger
# yum install curl-devel httpd-devel



  • Step#6: Compile the environment:

# passenger-install-apache2-module



  • Step#7 Edit the Apache config file in etc/httpd/conf/httpd.conf 
Uncomment the line containing NameVirtualHost *:80 towards the end
Paste the output from (Step#6 Compile environment) anywhere at the end of the file, eg:


# vim etc/httpd/conf/httpd.conf
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/buildout/apache2/mod_passenger.so

PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41

PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
<VirtualHost *:80>
 ServerName 1.2.3.4 # www.whatever.com
 DocumentRoot /var/www/rails/public # the path to your rails app
 <Directory /var/www/rails/public>
 AllowOverride all
 Options -MultiViews
 </Directory>
</VirtualHost>



3. References

https://www.digitalocean.com/community/tutorials/how-to-setup-a-rails-4-app-with-apache-and-passenger-on-centos-6
https://stackoverflow.com/questions/5584759/start-rails-server-automatically-after-boot