Dockerfile PostgreSQL Deployment

Source: Internet
Author: User
Tags postgres version docker run

(1) Docker Dockerfile

From centos:centos6 #使用的镜像名及其标记
Maintainer CXM <[email protected]>#建立此镜像的用户信息

RUN yum-y update; Yum Clean All #运行的命令
RUN yum-y install sudo epel-release;

#Sudo requires a TTY. Fix that.
RUN sed-i ' s/.*requiretty$/#Defaults requiretty/'/etc/sudoers

# Install PGDG repo for getting new Postgres RPMs
RUN RPM-IVHhttp://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm#安装数据库的centos源

# Install Postgres Version 9.4
RUN Yum Install postgresql94-server postgresql94 postgresql94-contrib postgresql94-plperl postgresql94-devel-y-- Nogpgcheck

volume/var/lib/pgsql/9.4 #磁盘
EXPOSE 5432 #对外开放5432端口

RUN yum-y Install vim
RUN yum-y Install make GCC

ENV path/usr/pgsql-9.4/bin: $PATH #添加环境变量


Note: Docker has a caching function, and when re-executing, the executed commands are no longer repeated, and if this function is not required, you can modify them yourself.


(2) Docker build

Docker build-t cxm:pg94--rm.

#--rm is the cache after execution,. Refers to the Dockerfile storage path is the current path under the Docker file


(3) Docker-server

Docker run--privileged-d--name pg94_run-p 15432:5432-v/pg94/bash_history:/root/.bash_history--volumes-from=pg94_d ATA--link redis_run:redis-v/pg94/src:/src-v/pg94/local:/usr/local cxm:pg94/sbin/init

Comments:

--privileged # Using this parameter, root in container has true root privileges

-D #后台运行

--name #给运行的容器命名

-p Host Port: Container port #指定容器的端口在宿主机的端口, that is, access the port of the host to access the port of the container

-V Host Path: Container path #与-P almost, but here refers to the file

--volumes-from=pg94_data #挂载容器所有的卷

--link Redis_run:redis #连接到另一个容器 (Name:alias)

cxm:pg94 #镜像名

/sbin/init #执行的终端命令


(4) Docker-client

Docker exec-it Pg94_run/bin/bash


This article is from the "Nobody Knows" blog, please be sure to keep this source http://cuixuemei.blog.51cto.com/8852728/1683457

Dockerfile PostgreSQL Deployment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.