(base) [root@dadevenv ~]# curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# Executing docker install script, commit: 26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c
+ sh -c 'yum install -y -q yum-utils'
No Presto metadata available for updates
+ sh -c 'yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo'
已加载插件:fastestmirror, langpacks
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/10): docker-ce-stable/x86_64/filelists_db | 21 kB 00:00:00
(2/10): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:00
(3/10): docker-ce-stable/x86_64/other_db | 114 kB 00:00:00
(4/10): extras/7/x86_64/filelists_db | 217 kB 00:00:01
(5/10): extras/7/x86_64/other_db | 124 kB 00:00:06
(6/10): updates/7/x86_64/filelists_db | 2.4 MB 00:00:05
(7/10): base/7/x86_64/filelists_db | 7.1 MB 00:00:10
(8/10): base/7/x86_64/other_db | 2.6 MB 00:00:12
(9/10): updates/7/x86_64/other_db | 318 kB 00:00:06
(10/10): docker-ce-stable/x86_64/primary_db | 46 kB 00:00:15
元数据缓存已建立
+ '[' -n '' ']'
+ sh -c 'yum install -y -q docker-ce'
No Presto metadata available for base
No Presto metadata available for updates
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.3.7-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
containerd.io-1.3.7-3.1.el7.x86_64.rpm 的公钥尚未安装
导入 GPG key 0x621E9F35:
用户ID : "Docker Release (CE rpm) <docker@docker.com>"
指纹 : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
来自 : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
setsebool: SELinux is disabled.
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker your-user
Remember that you will have to log out and back in for this to take effect!
WARNING: Adding a user to the "docker" group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.
(base) [root@dadevenv ~]# systemctl stop docker
(base) [root@dadevenv ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: inactive (dead) since 三 2020-10-14 11:04:05 CST; 5s ago
Docs: https://docs.docker.com
Process: 22671 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)
Main PID: 22671 (code=exited, status=0/SUCCESS)
10月 14 10:08:29 dadevenv dockerd[22671]: time="2020-10-14T10:08:29.958859994+...e"
10月 14 10:26:46 dadevenv dockerd[22671]: time="2020-10-14T10:26:46.508054178+...e"
10月 14 11:03:33 dadevenv dockerd[22671]: time="2020-10-14T11:03:33.645591213+...e"
10月 14 11:03:40 dadevenv dockerd[22671]: time="2020-10-14T11:03:40.610746576+...e"
10月 14 11:04:05 dadevenv systemd[1]: Stopping Docker Application Container En.....
10月 14 11:04:05 dadevenv dockerd[22671]: time="2020-10-14T11:04:05.184746754+...'"
10月 14 11:04:05 dadevenv dockerd[22671]: time="2020-10-14T11:04:05.185443832+...by
10月 14 11:04:05 dadevenv dockerd[22671]: time="2020-10-14T11:04:05.185740787+...e"
10月 14 11:04:05 dadevenv dockerd[22671]: time="2020-10-14T11:04:05.185773089+...by
10月 14 11:04:05 dadevenv systemd[1]: Stopped Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
(base) [root@dadevenv ~]# systemctl start docker
(base) [root@dadevenv ~]# 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 三 2020-10-14 11:04:26 CST; 1s ago
Docs: https://docs.docker.com
Main PID: 28052 (dockerd)
Tasks: 18
Memory: 44.0M
CGroup: /system.slice/docker.service
└─28052 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/contain...
10月 14 11:04:26 dadevenv dockerd[28052]: time="2020-10-14T11:04:26.711813261+...pc
10月 14 11:04:26 dadevenv dockerd[28052]: time="2020-10-14T11:04:26.711824798+...pc
10月 14 11:04:26 dadevenv dockerd[28052]: time="2020-10-14T11:04:26.722351901+...2"
10月 14 11:04:26 dadevenv dockerd[28052]: time="2020-10-14T11:04:26.728185654+...."
10月 14 11:04:26 dadevenv dockerd[28052]: time="2020-10-14T11:04:26.819309905+...s"
10月 14 11:04:26 dadevenv dockerd[28052]: time="2020-10-14T11:04:26.964120367+...."
10月 14 11:04:26 dadevenv dockerd[28052]: time="2020-10-14T11:04:26.980306177+...13
10月 14 11:04:26 dadevenv dockerd[28052]: time="2020-10-14T11:04:26.980374930+...n"
10月 14 11:04:26 dadevenv dockerd[28052]: time="2020-10-14T11:04:26.994692475+...k"
10月 14 11:04:26 dadevenv systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
(base) [root@dadevenv ~]#
拉取postgresql镜像
(base) [root@dadevenv ~]# docker pull postgres
Using default tag: latest
latest: Pulling from library/postgres
d121f8d1c412: Pull complete
9f045f1653de: Pull complete
fa0c0f0a5534: Pull complete
54e26c2eb3f1: Pull complete
cede939c738e: Pull complete
69f99b2ba105: Pull complete
218ae2bec541: Pull complete
70a48a74e7cf: Pull complete
c0159b3d9418: Pull complete
353f31fdef75: Pull complete
03d73272c393: Pull complete
8f89a54571bf: Pull complete
4885714928b5: Pull complete
3060b8f258ec: Pull complete
Digest: sha256:840ac924b4281002353b62528f5342c560f9d4882aec0fe4ba018d99b85d6141
Status: Downloaded newer image for postgres:latest
docker.io/library/postgres:latest
docker run -d --name=postgres -e POSTGRES_PASSWORD=root - p 5432:5432 postgres:latest
6124d94bc0c279081cb95f23a88c73e46c4d2fede26bb9ab29ca148159f65718
(base) [root@dadevenv ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6124d94bc0c2 postgres:latest "docker-entrypoint.s…" 6 seconds ago Up 6 seconds 0.0.0.0:5432->5432/tcp postgres
(base) [root@dadevenv ~]# docker exec -it 6124d94bc0c2 bash
root@6124d94bc0c2:/# psql -h localhost -Upostgres
psql (13.0 (Debian 13.0-1.pgdg100+1))
Type "help" for help.
postgres=#
postgres=# d
Did not find any relations.
postgres=# l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
postgres=#
停止镜像
(base) [root@dadevenv ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
88017aac9f1d postgres:latest "docker-entrypoint.s…" 26 minutes ago Up 26 minutes 0.0.0.0:5432->5432/tcp some-postgres
(base) [root@dadevenv ~]# docker stop 88017aac9f1d
(base) [root@dadevenv ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
docker run -p 5434:5432 -v /root/pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=postgres -e TZ=PRC -d --name=postgres postgres:latest
(base) [root@dadevenv ~]# docker pull timescale/timescaledb:2.0.0-rc1-pg12
2.0.0-rc1-pg12: Pulling from timescale/timescaledb
df20fa9351a1: Pull complete
600cd4e17445: Pull complete
04c8eedc9a76: Pull complete
e1426bb92bdb: Pull complete
a50b40f87c33: Pull complete
8f2ab59d35c2: Pull complete
40bf07073f77: Pull complete
42557388816c: Pull complete
52f3ad9159d7: Pull complete
7e177d86dea3: Pull complete
a7c057e59b29: Pull complete
04ce62b48456: Pull complete
582d071f19e9: Pull complete
Digest: sha256:9c628595f1df2dd05e94311b14f90259d5ddd3507066b0817657fc3615291dcf
Status: Downloaded newer image for timescale/timescaledb:2.0.0-rc1-pg12
docker.io/timescale/timescaledb:2.0.0-rc1-pg12
(base) [root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
timescale/timescaledb 2.0.0-rc1-pg12 400e121c59ef 6 days ago 179MB
postgres latest 817f2d3d51ec 2 weeks ago 314MB
创建本地数据存储目录
mkdir -p /root/timescaledbdata
docker run -p 5435:5432 -v /root/timescaledbdata:/var/lib/postgresql/data -d -e POSTGRES_PASSWORD=timescale --name=timescaledb timescale/timescaledb:2.0.0-rc1-pg12
psql -h 172.25.5.41 -U postgres -p 5435
Password for user postgres:
(base) [root@dadevenv ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5a1533767a6d timescale/timescaledb:2.0.0-rc1-pg12 "docker-entrypoint.s…" 9 minutes ago Up 9 minutes 0.0.0.0:5435->5432/tcp timescaledb
(base) [root@dadevenv ~]# docker stop 5a1533767a6d
5a1533767a6d
(base) [root@dadevenv ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5a1533767a6d timescale/timescaledb:2.0.0-rc1-pg12 "docker-entrypoint.s…" 22 minutes ago Exited (0) 6 seconds ago timescaledb
(base) [root@dadevenv ~]# docker start 5a1533767a6d
5a1533767a6d
(base) [root@dadevenv ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5a1533767a6d timescale/timescaledb:2.0.0-rc1-pg12 "docker-entrypoint.s…" 23 minutes ago Up 7 seconds
(base) [root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
timescale/timescaledb 2.0.0-rc1-pg12 400e121c59ef 7 days ago 179MB
postgres latest 817f2d3d51ec 2 weeks ago 314MB
(base) [root@dadevenv ~]# docker save -o postgresql.tar postgres:latest
(base) [root@dadevenv ~]# docker save -o timescaledb.tar timescale/timescaledb:2.0.0-rc1-pg12
(base) [root@dadevenv ~]# ll
总用量 492592
-rw-------. 1 root root 1694 10月 12 10:04 anaconda-ks.cfg
-rw-r--r--. 1 root root 1742 10月 12 10:44 initial-setup-ks.cfg
-rwxr-xr-x 1 root root 111 10月 12 13:53 jupyternotebook_start.sh
-rw-r--r-- 1 root root 67 10月 12 16:43 path.py
drwx------ 19 polkitd root 4096 10月 13 17:41 pgdata
-rw------- 1 root root 321790464 10月 14 10:20 postgresql.tar
drwxr-xr-x 3 root root 27 10月 12 16:20 PycharmProjects
drwx------ 19 avahi root 4096 10月 14 10:08 timescaledbdata
-rw------- 1 root root 182594560 10月 14 10:21 timescaledb.tar
删除镜像
先删除容器再删除镜像,否则用容器在使用镜像,就无法删除镜像,删除镜像就会报错
(base) [root@dadevenv ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5a1533767a6d timescale/timescaledb:2.0.0-rc1-pg12 "docker-entrypoint.s…" About an hour ago Exited (0) 5 seconds ago timescaledb
(base) [root@dadevenv ~]# docker rm 5a1533767a6d
5a1533767a6d
(base) [root@dadevenv ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
(base) [root@dadevenv ~]#
(base) [root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
timescale/timescaledb 2.0.0-rc1-pg12 400e121c59ef 7 days ago 179MB
postgres latest 817f2d3d51ec 2 weeks ago 314MB
(base) [root@dadevenv ~]# docker rmi -f 400e121c59ef
Untagged: timescale/timescaledb:2.0.0-rc1-pg12
Untagged: timescale/timescaledb@sha256:9c628595f1df2dd05e94311b14f90259d5ddd3507066b0817657fc3615291dcf
Deleted: sha256:400e121c59efd20a5d8dae346920fcbadcb56ea9c6255c87a8e262f9d4615dba
Deleted: sha256:cbcb889f8acb7037182bf51557393f039b045cfdf71e6bdf1f566a32ccb5e5ea
Deleted: sha256:36e93d3e3becd2a66c3cfb2db315c37932e2fcc9815ecbf250c607d39d8c675e
Deleted: sha256:ecf25325a512f3135d6b5b845dcb60e7cb99a1a163ba23f057d55a08c73d852a
Deleted: sha256:16c186b900ec931a101a0440e61a9df444b7f3ebb8d8d4a38c6218bbaa3b9c20
Deleted: sha256:8130c34c3797969fd104bc00fa69d2bca41bf76ab4976329fd6163a74e7282be
Deleted: sha256:5c4600d409785c7b5ed59f6fce735d0ad9dc2a11e00a53f860c0ef834ef34234
Deleted: sha256:532744ce39c36bcd8f09022b850bbe4bad98ef2e7ef085c4cc715d235b7f844e
Deleted: sha256:c697e9d1b098c38f9c8675200d48edbcb8b6a611c2a97227a804817f4391ffcb
Deleted: sha256:6e74af4be0b0085dffff9b43dc765121a5093a9687c7faf6059cac2ea21e3aca
Deleted: sha256:799411a482e701ffe066622ec22beb802d19534bccc490dce774784661606c65
Deleted: sha256:1546a64abdb698edf6075fc8f49d0fd9a87f4664ee11ef034c878234e39d1c08
Deleted: sha256:496ffdcbe16b07bf705464ea386906752a410d72a417e292c6d2f148918e7bf6
Deleted: sha256:50644c29ef5a27c9a40c393a73ece2479de78325cae7d762ef3cdc19bf42dd0a
(base) [root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
postgres latest 817f2d3d51ec 2 weeks ago 314MB
(base) [root@dadevenv ~]# docker rmi -f 817f2d3d51ec
Untagged: postgres:latest
Untagged: postgres@sha256:840ac924b4281002353b62528f5342c560f9d4882aec0fe4ba018d99b85d6141
Deleted: sha256:817f2d3d51eccb32a160cecca3b6bb95de017810498f1bb0a1d7627f59e3c5f9
Deleted: sha256:f129d29273cc0b7aa597502f4dce816fbf219e186cc4d3469084574ec3add5ba
Deleted: sha256:2afe8460604b177f834f0be1baacce9bbaf8b76dab822f9707154f317a106fc9
Deleted: sha256:48a572b0b067213717f89cc0c69b2ed07f298e39eda2547de03e70b8ee5a7c38
Deleted: sha256:8b502c3465d294c115f3362df39177b6c4126478773f6fc67a9cafbb2e2b6981
Deleted: sha256:cf507dd0064138ab6667763c156a1faba8f62cc73a0d20d515096e0f9e874826
Deleted: sha256:d52eacba2f4b050fb5cf846f120795cce83c70aa312c3928c1a9d1ae193580e1
Deleted: sha256:35c1acf0e0075ecea7e1650b9ee37c4a2e119070ce6fcc8f82cd2f4a8a061eb1
Deleted: sha256:5fed32dbbbd219cf0d7a3a3b372f1005f0132705c05a15e4a972e35d8bbdeed6
Deleted: sha256:c91270ef2ff80bc858249a6a70904419b3da6c88faf68ebcc405e67fe579ddc6
Deleted: sha256:93e69cdd16ed03440a0783cd1ff6892d3d7faf795315992726f5ea0977e35d8d
Deleted: sha256:8b83b573f5dec4d579291deef5be1eccd0bf79ef41ea2e26961b5472b9f3fc75
Deleted: sha256:9d9d3f04875ea561242877a370c072fd1fe1376004b4aa4967d0f1d1abdd1215
Deleted: sha256:7c87e41d03431fdde0e13603d09a9276a945e4e7a79e34cd1019078d58b71c1d
Deleted: sha256:07cab433985205f29909739f511777a810f4a9aff486355b71308bb654cdc868
(base) [root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
本机镜像加载到仓库
(base) [root@dadevenv ~]# docker load --help
Usage: docker load [OPTIONS]
Load an image from a tar archive or STDIN
Options:
-i, --input string Read from tar archive file, instead of STDIN
-q, --quiet Suppress the load output
(base) [root@dadevenv ~]# docker load -i postgresql.tar
07cab4339852: Loading layer 72.49MB/72.49MB
d711f79a038f: Loading layer 9.539MB/9.539MB
651a31113e01: Loading layer 339.5kB/339.5kB
7590cec527be: Loading layer 4.2MB/4.2MB
7e235619124d: Loading layer 25.51MB/25.51MB
6d86bd612d90: Loading layer 1.456MB/1.456MB
243029da6eb4: Loading layer 1.536kB/1.536kB
9ec659200e1a: Loading layer 6.656kB/6.656kB
aac7d8f9a4a2: Loading layer 208.1MB/208.1MB
818067c94118: Loading layer 64.51kB/64.51kB
ef1bd920c113: Loading layer 2.048kB/2.048kB
372bb6afef8c: Loading layer 3.072kB/3.072kB
48eb0b5eb968: Loading layer 14.34kB/14.34kB
680a586c04da: Loading layer 1.536kB/1.536kB
Loaded image: postgres:latest
(base) [root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
postgres latest 817f2d3d51ec 2 weeks ago 314MB
(base) [root@dadevenv ~]# docker load -i timescaledb.tar
50644c29ef5a: Loading layer 5.845MB/5.845MB
62c057152789: Loading layer 12.29kB/12.29kB
731b196c42df: Loading layer 1.536kB/1.536kB
219c943b113c: Loading layer 155.8MB/155.8MB
51e39043686b: Loading layer 30.21kB/30.21kB
4858bcffd700: Loading layer 2.048kB/2.048kB
55f33406abc3: Loading layer 3.072kB/3.072kB
374b69ee8317: Loading layer 14.34kB/14.34kB
4ffb06e15371: Loading layer 10.75kB/10.75kB
d67a332e9047: Loading layer 11.06MB/11.06MB
19086ec3cd01: Loading layer 4.627MB/4.627MB
7a928ecc5b89: Loading layer 562.7kB/562.7kB
c416566e7e5f: Loading layer 4.582MB/4.582MB
Loaded image: timescale/timescaledb:2.0.0-rc1-pg12
(base) [root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
timescale/timescaledb 2.0.0-rc1-pg12 400e121c59ef 7 days ago 179MB
postgres latest 817f2d3d51ec 2 weeks ago 314MB
运行容器
docker run -p 5434:5432 -v /root/pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=postgres -e TZ=PRC -d --name=postgres postgres:latest
postgresql数据库容器操作
1.导入postgresql镜像
(base) [root@dadevenv ~]# docker load -i postgresql.tar
07cab4339852: Loading layer 72.49MB/72.49MB
d711f79a038f: Loading layer 9.539MB/9.539MB
651a31113e01: Loading layer 339.5kB/339.5kB
7590cec527be: Loading layer 4.2MB/4.2MB
7e235619124d: Loading layer 25.51MB/25.51MB
6d86bd612d90: Loading layer 1.456MB/1.456MB
243029da6eb4: Loading layer 1.536kB/1.536kB
9ec659200e1a: Loading layer 6.656kB/6.656kB
aac7d8f9a4a2: Loading layer 208.1MB/208.1MB
818067c94118: Loading layer 64.51kB/64.51kB
ef1bd920c113: Loading layer 2.048kB/2.048kB
372bb6afef8c: Loading layer 3.072kB/3.072kB
48eb0b5eb968: Loading layer 14.34kB/14.34kB
680a586c04da: Loading layer 1.536kB/1.536kB
Loaded image: postgres:latest
(base) [root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
postgres latest 817f2d3d51ec 2 weeks ago 314MB
2.创建本地数据存储目录
mkdir -p /root/pgdata
3.启动postgresql容器
(base) [root@dadevenv ~]# docker run -p 5434:5432 -v /root/pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=postgres -e TZ=PRC -d --name=postgres postgres:latest
1f2f61c276e06b7c067b33681827823809a74bb20b87db1413ae9c78cdc19347
(base) [root@dadevenv ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1f2f61c276e0 postgres:latest "docker-entrypoint.s…" 9 seconds ago Up 8 seconds 0.0.0.0:5434->5432/tcp postgres
4.连接postgresql容器中运行的数据库
[postgres@DM04 ~]$ psql -h 172.25.5.41 -U postgres -p 5434
Password for user postgres:
psql (9.2.24, server 13.0 (Debian 13.0-1.pgdg100+1))
WARNING: psql version 9.2, server version 13.0.
Some psql features might not work.
Type "help" for help.
timescaledb数据库容器操作
1.导入timescaledb镜像
(base) [root@dadevenv ~]# docker load -i timescaledb.tar
50644c29ef5a: Loading layer 5.845MB/5.845MB
62c057152789: Loading layer 12.29kB/12.29kB
731b196c42df: Loading layer 1.536kB/1.536kB
219c943b113c: Loading layer 155.8MB/155.8MB
51e39043686b: Loading layer 30.21kB/30.21kB
4858bcffd700: Loading layer 2.048kB/2.048kB
55f33406abc3: Loading layer 3.072kB/3.072kB
374b69ee8317: Loading layer 14.34kB/14.34kB
4ffb06e15371: Loading layer 10.75kB/10.75kB
d67a332e9047: Loading layer 11.06MB/11.06MB
19086ec3cd01: Loading layer 4.627MB/4.627MB
7a928ecc5b89: Loading layer 562.7kB/562.7kB
c416566e7e5f: Loading layer 4.582MB/4.582MB
Loaded image: timescale/timescaledb:2.0.0-rc1-pg12
(base) [root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
timescale/timescaledb 2.0.0-rc1-pg12 400e121c59ef 7 days ago 179MB
postgres latest 817f2d3d51ec 2 weeks ago 314MB
2.创建本地数据存储目录
mkdir -p /root/timescaledbdata/
3.启动timescaledb容器
docker run -p 5435:5432 -v /root/timescaledbdata:/var/lib/postgresql/data -d -e POSTGRES_PASSWORD=timescale --name=timescaledb timescale/timescaledb:2.0.0-rc1-pg12
4.连接timescaledb容器中运行的数据库
[postgres@DM04 ~]$ psql -h 172.25.5.41 -U postgres -p 5435
Password for user postgres:
psql (9.2.24, server 12.4)
WARNING: psql version 9.2, server version 12.0.
Some psql features might not work.
Type "help" for help.
MySQL
查找Docker Hub上的MySQL镜像
docker search mysql
拉取官方的镜像,标签为5.6
docker pull mysql:5.6
在本地镜像列表里查到REPOSITORY为mysql,标签为5.6的镜像。
docker images |grep mysql
创建目录mysql,用于存放后面的相关东西。
mkdir -p ~/mysql/data ~/mysql/logs ~/mysql/conf
data目录将映射为mysql容器配置的数据文件存放路径
logs目录将映射为mysql容器的日志目录
conf目录里的配置文件将映射为mysql容器的配置文件
运行容器
docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
-p 3306:3306:将容器的 3306 端口映射到主机的 3306 端口。
-v -v $PWD/conf:/etc/mysql/conf.d:将主机当前目录下的 conf/my.cnf 挂载到容器的 /etc/mysql/my.cnf。
-v $PWD/logs:/logs:将主机当前目录下的 logs 目录挂载到容器的 /logs。
-v $PWD/data:/var/lib/mysql :将主机当前目录下的data目录挂载到容器的 /var/lib/mysql 。
-e MYSQL_ROOT_PASSWORD=123456:初始化 root 用户的密码。
查看容器启动情况
docker ps
进入容器
docker exec -it mysql bash
登录MySQL
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Lzslov123!';
添加远程登录用户
CREATE USER 'liaozesong'@'%' IDENTIFIED WITH mysql_native_password BY 'Lzslov123!';
GRANT ALL PRIVILEGES ON *.* TO 'liaozesong'@'%';