Portainer
https://www.portainer.io/installation/
docker volume create portainer_data docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/opt/portainer portainer/portainer
-v portainer_data:/opt/portainer portainer/portainer:數據目錄
MySQL
https://hub.docker.com/_/mysql
docker run --restart=always --name mysql \ -v /opt/mysql/data:/var/lib/mysql \ -v /opt/mysql/log:/var/log/mysql \ -v /opt/mysql/conf:/etc/mysql/conf.d \ -e MYSQL_ROOT_PASSWORD=root -e MYSQL_ROOT_HOST=% -e TZ=Asia/Shanghai \ -p 3306:3306 -d mysql:latest
docker mysql 連接慢:https://dev.mysql.com/doc/refman/8.0/en/host-cache.html
https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_skip_name_resolve
vim /opt/mysql/conf/config-file.cnf [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] max_connections = 1000 default-time-zone = '+08:00' init_connect = 'SET collation_connection = utf8mb4_unicode_ci' init_connect = 'SET NAMES utf8mb4' character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci skip-character-set-client-handshake skip-name-resolve
MySQL Config:https://www.cnblogs.com/jhxxb/p/13291593.html
查看幫助
docker run -it --rm mysql:latest --verbose --help
MYSQL_ROOT_PASSWORD:root 密碼
MYSQL_ROOT_HOST:root 用戶遠程訪問,% 表示任意地址
TZ:時區
其它可用環境變量:https://dev.mysql.com/doc/refman/5.7/en/environment-variables.html
-v /opt/mysql/data:/var/lib/mysql:數據目錄
-v /opt/mysql/conf:/etc/mysql/conf.d:配置目錄,MySQL 實例從采用混合(/etc/mysql/my.cnf 和自定義配置)設置
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
MariaDB
docker run --name my-mariadb \ -v /opt/mariadb/conf:/etc/mysql/conf.d \ -v /opt/mariadb/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=root \ -p 3306:3306 -d mariadb:10.5.8 \ --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
https://hub.docker.com/_/mariadb
RabbitMQ
docker run --restart=always -d --name rabbitmq --hostname my-rabbit \ -e RABBITMQ_DEFAULT_VHOST=my_vhost -e RABBITMQ_DEFAULT_USER=guest -e RABBITMQ_DEFAULT_PASS=guest \ -p 5672:5672 -p 15672:15672 \ -v /opt/rabbitmq:/var/lib/rabbitmq/mnesia \ rabbitmq:management-alpine
https://hub.docker.com/_/rabbitmq
Jenkins
https://www.jenkins.io/zh/doc/book/installing
https://www.jenkins.io/doc/book/installing/#installing-docker
# 創建網橋網絡 docker network create jenkins # 創建數據卷,持久化 Jenkins 數據 docker volume create jenkins-data docker run \ --restart=always \ -u root \ -d \ -p 8090:8080 \ -p 50000:50000 \ -v /home/jenkins/data:/var/jenkins_home \ -v /home/jenkins/tools:/tools \ -v /home/jenkins/docker.sock:/var/run/docker.sock \ jenkinsci/blueocean
https://www.jenkins.io/doc/book/installing/#setup-wizard
指定用戶:--user $(id -u),默認用戶為 guest
jenkins-data 數據卷默認路徑:/var/lib/docker/volumes/jenkins-data/_data
ElasticSearch
IK 分詞:https://github.com/medcl/elasticsearch-analysis-ik/releases
mkdir -p /opt/elasticsearch/config mkdir -p /opt/elasticsearch/data mkdir -p /opt/elasticsearch/plugins echo "http.host: 0.0.0.0" >> /opt/elasticsearch/config/elasticsearch.yml docker run --restart=always --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -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.9.3 docker run --restart=always --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.8.121:9200 -p 5601:5601 -d kibana:7.9.3
將 IK 分詞插件解壓后放置 /opt/elasticsearch/plugins 下,重啟 ES 容器即可,注意 IK 版本要與 ES 版本對應
查看 IK 是否安裝成功
# 查看 ES 容器 ID docker ps # 進入 ES 容器 docker exec -it 59a00c5f46cb /bin/bash # 列出所有已安裝插件 ./bin/elasticsearch-plugin list # 退出容器,不會關閉容器 exit
Redis
https://hub.docker.com/_/redis
mkdir -p /opt/redis/data mkdir -p /opt/redis/conf # touch /opt/redis/conf/redis.conf echo "appendonly yes" >> /opt/redis/conf/redis.conf # 要存在 /opt/redis/conf/redis.conf 文件 docker run --restart=always --name redis \ -v /opt/redis/data:/data \ -v /opt/redis/conf/redis.conf:/etc/redis/redis.conf \ -p 6379:6379 -d redis:alpine \ redis-server /etc/redis/redis.conf # 連接 Redis docker exec -it redis redis-cli quit
Prometheus
docker run -d -p 9090:9090 -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml --name prometheus prom/prometheus
/opt/prometheus/prometheus.yml
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: 'spis'
scrape_interval: 60s
scrape_timeout: 10s
metrics_path: '/spis/actuator/prometheus'
static_configs:
- targets: ['xxx:80','xxx:8080']
http://xxx:9090/targets
Grafana
docker run -d -p 3000:3000 --name grafana -v /opt/grafana:/var/lib/grafana grafana/grafana
默認用戶名密碼都是 admin,第一次登錄后需要設置新密碼
https://www.cnblogs.com/larrydpk/p/12563497.html
https://grafana.com/grafana/dashboards
Nexus3
mkdir /opt/nexus3 && chown -R 200 /opt/nexus3 docker run -d -p 8081:8081 --restart=always --name nexus3 -v /opt/nexus3:/nexus-data sonatype/nexus3
用戶名:admin,密碼:cat /home/nexus3/admin.password
https://hub.docker.com/r/sonatype/nexus3
配置 maven 程序中的 settings.xml
<server> <id>xxx-xxx</id> <!-- 隨意 --> <username>admin</username> <password>admin</password> </server> </servers>
配置要上傳 jar 包項目中的 pom.xml,執行 deploy 就會上傳
<distributionManagement> <repository> <!--這里的 id 需要和 settings.xml 中 server 的 id 一致--> <id>xxx-xxx</id> <url>http://xxx.xxx.xxx.xxx:8081/repository/xxx-xxx/</url> </repository> </distributionManagement>
配置要使用 jar 包中的 pom.xml
<repositories> <repository> <id>xxx-xxx</id> <url>http://xxx.xxx.xxx.xxx:8081/repository/xxx-xxx/</url> </repository> </repositories>
https://blog.csdn.net/mytt_10566/article/details/78966577
Tomcat
https://registry.hub.docker.com/_/tomcat
docker run -d -p 8888:8080 \ -v /home/dsw/docker/tomcat/logs/:/usr/local/tomcat/logs/ \ -v /home/dsw/docker/tomcat/webapps/:/usr/local/tomcat/webapps/ \ tomcat:9.0
容器內安裝 vim
docker exec -it --user root xxxxxxxx /bin/bash cp /etc/apt/sources.list /etc/apt/sources.list.bak sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list apt-get update apt-get install vim
manager-gui 配置:https://www.cnblogs.com/jhxxb/p/11240356.html
Oracle DataBase
https://hub.docker.com/r/loliconneko/oracle-ee-11g
也可自己構建鏡像:https://www.cnblogs.com/jhxxb/p/14991326.html
docker run --restart=always --name oracle-11g \ -v /home/dsw/oracle:/u01/app/oracle \ -e WEB_CONSOLE=false \ -e DBCA_TOTAL_MEMORY=4096 \ -p 1521:1521 \ -d loliconneko/oracle-ee-11g
連接信息
hostname: localhost port: 1521 sid: EE service name: EE.oracle.docker username: system password: oracle
運行 Java 應用
構建 oracle java 鏡像:https://github.com/oracle/docker-images/tree/main/OracleJava
與構建 oracle database 類似:https://www.cnblogs.com/jhxxb/p/14991326.html
docker run -d --restart=always --name springboot \ -v /opt/springboot:/java \ -p 9000:9000 \ oracle/serverjre:8-oraclelinux7 \ java -Dspring.profiles.active=dev -Dserver.port=9000 -Dlogging.file.name=/java/logs/file.log -jar /java/springboot.jar
