下载和启动 Mac Docker
image.png后续的都是控制台的操作
安装 PostgreSQL
参考 https://www.jianshu.com/p/900345a369aa
拉取镜像
> docker pull postgres:9.6
9.6: Pulling from library/postgres
fc7181108d40: Pull complete
81cfa12d39e9: Pull complete
793d305ca761: Pull complete
41e3ced3a2aa: Pull complete
a300bc9d5405: Pull complete
3c6a5c3830ed: Pull complete
fb8c79b24338: Pull complete
fcda1144379f: Pull complete
1b6bdda9a7d0: Pull complete
3f44e35d537d: Pull complete
9161ffee7255: Pull complete
b6569cb49b8b: Pull complete
21e1e65283f8: Pull complete
4cbcde26ced5: Pull complete
Digest: sha256:de03034bae132f5cc0672f6c1a0a3a5591a0640cad6b21f2b0d00fc0ce15ab15
Status: Downloaded newer image for postgres:9.6
创建本地卷
> docker volume create pgdata
pgdata
启动容器
> docker run -it --rm -v pgdata:/var/lib/postgresql/data -p 5432:5432 postgres:9.6
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
...
进入容器创建数据
查看该容器 ID
> docker ps
假设该容器 ID 为 123 ,新开一个 Terminal 进入容器
> docker exec -it 123 /bin/bash
后续就可以做创建用户,创建表相关的操作了。
使用 Navicat 连接
host: localhost
port: 5432
initial database: postgres
username: postgres
password: 123456
安装 Oracle
参考 https://blog.csdn.net/master_shifu_/article/details/80790218
拉取镜像
docker pull oracleinanutshell/oracle-xe-11g
启动容器
docker run -d -p 9090:8080 -p 1521:1521 oracleinanutshell/oracle-xe-11g
命令解释:将容器中的Oracle XE 管理界面的8080端口映射为本机的9090端口,将Oracle XE的1521端口映射为本机的1521端口
使用 Navicat 连接
host: localhost
port: 1521
SID : XE
username: system/sys
password: oracle
安装 SQLServer
参考 https://segmentfault.com/a/1190000014232366
拉取镜像
docker pull microsoft/mssql-server-linux
创建并运行容器
docker run --name MSSQL_1433 -m 512m -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=YourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux
替换YourStrong(!)Password成你自己的密码,这个密码需要复杂密码,要有大小写和特殊符号。
登入容器
docker exec -it MSSQL_1433 /bin/bash
连接到sqlcmd
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong(!)Password'
执行SQL语句创建数据库
CREATE DATABASE test_db
go
使用 Navicat 连接
host: localhost
port: 1433
initial database: master
username: SA
password: YourStrong(!)Password
网友评论