CentOS 7.6上启动PostgresSQL docker容器数据库步骤

步骤1:使用root用户登录操作系统(如果是ubuntu用户登录的话,使用sudo切换到root)

步骤2:确保docker服务已经启动

2.1 查询docker运行状态systemctl status docker

CentOS 7.6操作系统docker服务默认是没有启动的。

[root@localhost ubuntu]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.docker.com
2.2 启动docker服务systemctl start docker,并查看启动是否成功systemctl status docker
[root@localhost ubuntu]# systemctl start docker
[root@localhost ubuntu]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 四 2022-10-06 05:07:06 CST; 2min 27s ago
     Docs: https://docs.docker.com
 Main PID: 18456 (dockerd)
    Tasks: 37
   Memory: 126.1M
   CGroup: /system.slice/docker.service
           └─18456 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

10月 06 05:07:04 localhost.localdomain dockerd[18456]: time="2022-10-06T05:07:04.596236417+08:00" level=info msg="Loading containers: start."
10月 06 05:07:05 localhost.localdomain dockerd[18456]: time="2022-10-06T05:07:05.182555349+08:00" level=info msg="Firewalld: docker zone already exists, returning"
10月 06 05:07:05 localhost.localdomain dockerd[18456]: time="2022-10-06T05:07:05.700072429+08:00" level=info msg="Firewalld: interface docker0 already part...eturning"
10月 06 05:07:06 localhost.localdomain dockerd[18456]: time="2022-10-06T05:07:06.128544874+08:00" level=info msg="Default bridge (docker0) is assigned with... address"
10月 06 05:07:06 localhost.localdomain dockerd[18456]: time="2022-10-06T05:07:06.306848316+08:00" level=info msg="Firewalld: interface docker0 already part...eturning"
10月 06 05:07:06 localhost.localdomain dockerd[18456]: time="2022-10-06T05:07:06.596667518+08:00" level=info msg="Loading containers: done."
10月 06 05:07:06 localhost.localdomain dockerd[18456]: time="2022-10-06T05:07:06.915053921+08:00" level=info msg="Docker daemon" commit=79ea9d3 graphdriver...n=20.10.9
10月 06 05:07:06 localhost.localdomain dockerd[18456]: time="2022-10-06T05:07:06.915510778+08:00" level=info msg="Daemon has completed initialization"
10月 06 05:07:06 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
10月 06 05:07:06 localhost.localdomain dockerd[18456]: time="2022-10-06T05:07:06.968910150+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.

步骤3:启动PG镜像docker run -d -e POSTGRES_PASSWORD=tiger postgres:10.17

后台模式运行容器:

$docker images|grep pos #查看有哪些pg镜像可用
$ docker run -d -e POSTGRES_PASSWORD=tiger postgres:10.17

$ docker ps

(非后台模式去掉-d参数,docker run -e POSTGRES_PASSWORD=tiger postgres:10.17)

[root@localhost ubuntu]# docker run -d -e POSTGRES_PASSWORD=tiger postgres:10.17
876e47b8f7a6043494c8567b26c5dc018d86d5dec3a44d7b4efa70d047af9774
[root@localhost ubuntu]# docker ps
CONTAINER ID   IMAGE            COMMAND                  CREATED         STATUS         PORTS      NAMES
876e47b8f7a6   postgres:10.17   "docker-entrypoint.s…"   9 minutes ago   Up 9 minutes   5432/tcp   happy_diffie
[root@localhost ubuntu]#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值