docker启动各应用
docker的入门可参考各种大佬的教程,这里只记录自己常用应用的命令,方便做平时使用
–restart=always 启动docker时自动启动
1.MySQL
docker run -d -p 3306:3306 -v E:/DB/MySQL5.7/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD='1qaz@WSX3edc' --name mysql mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
docker run -d -p 3306:3306 -v /data/mysql6033/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD='1qaz@WSX3edc' --name mysql8 mysql:8.3 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
表示映射宿主机3306端口到容器内部的3306端口,mysql连接密码,配置了mysql数据目录在宿主机的链接,设置了mysql编码为utf8mb4。(可添加配置映射 -v E:/DB/MySQL5.7/conf/my.cnf:/etc/my.cnf)
2.Redis
docker run -p 6379:6379 --name redis -v E:/DB/redis/data:/data --restart=always -d redis:latest redis-server
docker与宿主机的端口映射,启动命名redis容器的名字,挂载redis.conf文件,挂在redis的持久化数据,设置redis容器随docker启动而自启动,指定redis在docker中的配置文件路径,-d后台启动redis(可添加配置映射 -v E:/DB/redis/redis.conf:/etc/redis/redis.conf /etc/redis/redis.conf )
3.IBM MQ
# 拉取 ibm mq 镜像
# docker仓库地址:https://hub.docker.com/r/ibmcom/mq/
# 该镜像的默认用户是admin,密码是 passw0rd
docker pull ibmcom/mq
# 启动mq
docker run --env LICENSE=accept --env MQ_QMGR_NAME=QM1 --publish 1414:1414 --publish 9443:9443 --detach ibmcom/mq
参考链接: https://www.likecs.com/show-306614019.html
4.ArchLinux
docker run -it -p 2222:22 --name archLinux archlinux:latest
参考 https://mogeko.me/posts/zh-cn/063/
5.Elasticsearch
#创建容器挂载的目录
mkdir -p /opt/elasticsearch/config & mkdir -p /opt/elasticsearch/data & mkdir -p /opt/elasticsearch/plugins
chmod 777 /opt/elasticsearch/data
#配置文件
echo "http.host: 0.0.0.0" >> /opt/elasticsearch/config/elasticsearch.yml
#创建容器
# linux
docker run --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms84m -Xmx512m" -v /opt/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /opt/elasticsearch/data:/usr/share/elasticsearch/data -v /opt/elasticsearch/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:7.12.0
# windows
docker run --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms84m -Xmx512m" -v G:\\IT\\docker_container\\elasticsearch\\config\\elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v G:\\IT\\docker_container\\elasticsearch\\data:/usr/share/elasticsearch/data -v G:\\IT\docker_container\\elasticsearch\\plugins:/usr/share/elasticsearch/plugins -d elasticsearch:7.12.0
6.Cerebro
Elasticsearch的客户端,访问:localhost:9000
docker run --name cerebro -d -p 9000:9000 lmenezes/cerebro:0.8.4
需要注意的是由于cerebro运行在容器中,直接输入localhost:9200即使通过浏览器能够访问也可能无法连接,需要保证的是在cerebro的容器中能够访问到的URL,比如这里使用的本机的IP
参考:https://liumiaocn.blog.csdn.net/article/details/98517815
7.Oracle
docker pull container-registry.oracle.com/database/free:latest
# 或者
docker run -d -p 1521:1521 -p 5500:5500 -e ORACLE_SID=ORCL -e ORACLE_PDB=ORCLPDB -e ORACLE_PWD=1qaz@WSX3edc -e ORACLE_EDITION=standard -e ORACLE_CHARACTERSET=ZHS16GBK -v D:\DATA\DockerDesktopWSL\oracle19c\oradata:/opt/oracle/oradata --name oracle19c doctorkirk/oracle-19c:19.9
参考:https://www.oracle.com/tw/database/technologies/oracle-database-software-downloads.html#19c
https://huaweicloud.csdn.net/638db519dacf622b8df8cd3e.html
连接oracle:
#打开容器终端
docker exec -it oracle19c /bin/bash
#sqlplus登录
#sysdba身份登录,默认进入CDB
sqlplus / as sysdba
#进入CDB
sqlplus system/orcl@localhost:1521/orcl
#进入PDB
sqlplus pdbadmin/orcl@localhost:1521/orclpdb
#查看连接模式
SQL>show con_name
8.Nginx
- 准备工作:先在主机创建工作文件夹,为了挂载配置和静态文件的访问使用
#启动一个容器
docker run -d --name nginx nginx
# 查看 容器 获取容器ID 或直接使用名字
docker container ls
# 在当前目录下创建目录:conf
mkdir conf
# 拷贝容器内 Nginx 默认配置文件到本地当前目录下的 conf 目录($PWD 当前全路径)
# 注意当前 nginx 是 nignx所在的容器名字
docker cp nginx:/etc/nginx/nginx.conf $PWD/conf
docker cp nginx:/etc/nginx/conf.d $PWD/conf
# 停止容器
docker container stop nginx
# 删除容器
docker container rm nginx
# 在当前目录下创建目录:html 放静态文件
- 重新部署容器
docker run -d -p 80:80 \
--name nginx-prod \
-v /root/nginx/html:/usr/share/nginx/html \
-v /root/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /root/nginx/logs:/var/log/nginx nginx
-d # 表示在一直在后台运行容器
-p 80:80 # 对端口进行映射,将本地8081端口映射到容器内部的80端口
–name # 设置创建的容器名称
-v # 将本地目录(文件)挂载到容器指定目录;
–link answer-server:answerserver 这计划是指需要转向本机docker容器的别名
- nginx配置文件修改
server {
listen 443 ssl;
server_name yuming.cpm; #你的申请过证书的域名
ssl_certificate /etc/nginx/conf.d/certs/xxxx.pem;
ssl_certificate_key /etc/nginx/conf.d/certs/xxxx.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location / {
root /usr/share/nginx/html/admin;
index index.html index.htm;
}
location /admin {
alias /usr/share/nginx/html/admin;
index index.html index.htm;
}
location /s {
proxy_pass http://mallservertest:8080/;
}
}
9.OpenGauss
docker run --name opengauss --privileged=true -d -e GS_PASSWORD=openGauss@123 -v d:\dbData\opengauss\data:/var/lib/opengauss/data opengauss/opengauss:5.0.0
10.OceanBase
obd部署单节点数据库
docker run -d -m 12G --cpus 4 --name oceanbase-ce oceanbase/oceanbase-ce
#切换终端到docker容器
docker exec -it oceanbase-ce bash
#检查集群状态
obd cluster list
#启动集群
obd cluster start 集群名
#停止集群
obd cluster stop 集群名
#重启集群
obd cluster restart 集群名
#查看集群状况
obd cluster list
obd cluster display 集群名
#查看集群配置,也可以根据模板,重新建一个配置文件,重新部署新集群
obd cluster edit-config 集群名
#连接客户端
obclient -h127.0.0.1 -P2881 -uroot@sys -p -c -A -Doceanbase
-- 修改root密码
alter user root identified by 'root';
11.StarRocks
docker-compose.yml
version: "3"
services:
minio:
container_name: minio
environment:
MINIO_ROOT_USER: miniouser
MINIO_ROOT_PASSWORD: miniopassword
image: minio/minio:latest
volumes:
- ./minio/data:/minio_data
ports:
- "9001:9001"
- "9000:9000"
entrypoint: sh
command: '-c ''mkdir -p /minio_data/starrocks && minio server /minio_data --console-address ":9001"'''
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 5s
timeout: 5s
retries: 5
minio_mc:
# This service is short lived, it does this:
# - starts up
# - checks to see if the MinIO service `minio` is ready
# - creates a MinIO Access Key that the StarRocks services will use
# - exits
image: minio/mc:latest
entrypoint:
- sh
- -c
- |
until mc ls minio > /dev/null 2>&1; do
sleep 0.5
done
mc alias set myminio http://minio:9000 miniouser miniopassword
mc admin user svcacct add --access-key AAAAAAAAAAAAAAAAAAAA \
--secret-key BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB \
myminio \
miniouser
depends_on:
- minio
starrocks-fe:
image: starrocks/fe-ubuntu:3.2-latest
hostname: starrocks-fe
container_name: starrocks-fe
user: root
volumes:
- ./starrocks/fe/meta:/opt/starrocks/fe/meta
- ./starrocks/fe/log:/opt/starrocks/fe/log
command:
- /bin/bash
- -c
- |
echo "# enable shared data, set storage type, set endpoint" >> /opt/starrocks/fe/conf/fe.conf
echo "run_mode = shared_data" >> /opt/starrocks/fe/conf/fe.conf
echo "cloud_native_storage_type = S3" >> /opt/starrocks/fe/conf/fe.conf
echo "aws_s3_endpoint = minio:9000" >> /opt/starrocks/fe/conf/fe.conf
echo "# set the path in MinIO" >> /opt/starrocks/fe/conf/fe.conf
echo "aws_s3_path = starrocks/shared/" >> /opt/starrocks/fe/conf/fe.conf
echo "# credentials for MinIO object read/write" >> /opt/starrocks/fe/conf/fe.conf
echo "aws_s3_access_key = AAAAAAAAAAAAAAAAAAAA" >> /opt/starrocks/fe/conf/fe.conf
echo "aws_s3_secret_key = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" >> /opt/starrocks/fe/conf/fe.conf
echo "aws_s3_use_instance_profile = false" >> /opt/starrocks/fe/conf/fe.conf
echo "aws_s3_use_aws_sdk_default_behavior = false" >> /opt/starrocks/fe/conf/fe.conf
echo "# Set this to false if you do not want default" >> /opt/starrocks/fe/conf/fe.conf
echo "# storage created in the object storage using" >> /opt/starrocks/fe/conf/fe.conf
echo "# the details provided above" >> /opt/starrocks/fe/conf/fe.conf
echo "enable_load_volume_from_conf = false" >> /opt/starrocks/fe/conf/fe.conf
/opt/starrocks/fe/bin/start_fe.sh
environment:
- HOST_TYPE=FQDN
- TZ=Asia/Shanghai
ports:
- 8030:8030
- 9020:9020
- 9030:9030
healthcheck:
test: 'mysql -u root -h starrocks-fe -P 9030 -e "show frontends\G" |grep "Alive: true"'
interval: 10s
timeout: 5s
retries: 3
depends_on:
- minio
starrocks-cn:
image: starrocks/cn-ubuntu:3.2-latest
command:
- /bin/bash
- -c
- |
sleep 15s;
ulimit -u 65535;
ulimit -n 65535;
/opt/starrocks/cn/bin/start_cn.sh
environment:
- HOST_TYPE=FQDN
- TZ=Asia/Shanghai
ports:
- 8040:8040
volumes:
- ./starrocks/cn/storage:/opt/starrocks/cn/storage
- ./starrocks/cn/log:/opt/starrocks/cn/log
hostname: starrocks-cn
container_name: starrocks-cn
user: root
depends_on:
- starrocks-fe
- minio
healthcheck:
test: 'mysql -u root -h starrocks-fe -P 9030 -e "SHOW COMPUTE NODES\G" |grep "Alive: true"'
interval: 10s
timeout: 5s
retries: 3
12.MongoDB
https://gitcode.csdn.net/65ed7a3b1a836825ed79aac5.html
docker run -dit --name mongo -p 27017:27017 mongo:latest --auth
13.NebulaGraph
安装步骤参考: https://docs.nebula-graph.com.cn/3.8.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/3.deploy-nebula-graph-with-docker-compose/