Docker Postgresql installation quickly

Task introduction

1.Docker
1.1. Docker Installation
2. Find the mirror
3. Download the mirror
4. View the mirror
5. Create a container and run it through mirroring
6. Delete the container and create a data directory for host mapping postgres
7. Check the status of the postgres container
8, enter the postgres container
9. Connection test outside the container-Complete port mapping so that external machines can access the database in the virtual machine
10. Other linking methods

1.Docker:

Docker is a cloud open source project. Powerful, scalable and lightweight container solutions are provided by Docker. The main goal of Docker is “Build, Ship and Run Any App, Anywhere”.

The Linux Container (LXC) technology is the base of the Docker engine. Docker further optimizes the use experience of containers on the basis of LXC and, at the same time, offers different container management resources (such as distribution, version, migration, etc.) so that users do not have to pay attention to the underlying operations.

1.1 Docker Installation

The company plans to use Docker to deploy projects in the near future, take the opportunity to learn more.

My Laptop configuration is Core i5, single core, 8g storage, 100g hard drive
Docker allows the Centos framework kernel version to be greater than 3.10, so first verify that the docker can be installed on your computer.
Execute on the computer the following commands:

After a bunch of cool linux information screens, you can officially start installing docker

Note:

Docker adopts the timeline method as the version number since version 1.13, divided into community version CE and enterprise version EE.

The community version is free for individual developers and small groups to use, and the enterprise version will provide additional paid services, such as infrastructure, containers, and plug-ins that have been officially tested and certified.

The community version is released in two ways: stable and edge. The stable version is updated quarterly, such as 17.06, 17.09; the edge version is updated every month, such as 17.09, 17.10.

My current installation method is not the latest installation method, but the last version before the Docker distribution. Can use:

2. Find the mirror

[root@pankajconnect ~]# docker search postgres

3. Download the mirror

4. View the mirror

5. Create a container and run it through mirroring

[root@pankajconnect ~]# docker run — name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres

Success. You can now start the database server using:

pg_ctl -D /var/lib/postgresql/data -l logfile start

6. Delete the container and create a data directory for host mapping postgres

[root@pankajconnect ~]# docker ps -a

[root@pankajconnect ~]# docker rm e63b736f0f3f

Create a data directory for host mapping postgres

7. Check the status of the postgresql container

[root@pankajconnect data]# docker ps -a

8, enter the postgres container

[root@pankajconnect data]# docker exec -it postgres /bin/bash
root@aec8a31d2ae1:/# ls

postgres@aec8a31d2ae1:~$
9. Connection test outside the container-Complete port mapping so that external machines can access the database in the virtual machine

Error: No psql client installed

[root@pankajconnect ~]# yum install postgresql

10. Other linking methods

In fact, the container also has its own IP address in /var/lib/docker/containers/container ID/hosts

I like to learn new and better ways of doing things when working on a scale, and feel free to ask questions and make suggestions.
Also, check out another story on this.
Thanks for reading this.

--

--

Database/System Administrator | DevOPS | Cloud Specialist | DevOPS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pankaj kushwaha

Database/System Administrator | DevOPS | Cloud Specialist | DevOPS