文章目录

Docker常用容器安装

Docker 命令参数说明:

参数 说明
-d 后台运行
-p 指定端口
-v 文件挂载  -v 本地目录:容器目录
—restart 始终保存启动
—name 指定容器名称

进入容器命令:

docker exec -it [容器名称] /bin/bash

1.Redis安装命令

docker run -d \
--restart=always \
--name xwder-redis \
-p 6379:6379 \
-v /etc/localtime:/etc/localtime \
-v /usr/local/docker/redis/conf/redis.conf:/redis.conf \
-v /usr/local/docker/redis/data:/data redis redis-server \
--appendonly yes \
--requirepass "9t6U3OBxxd"

2.jenkins安装命令

docker run -d \
-p 9001:8080 -p 50000:50000 \
-v /usr/local/docker/jenkins:/var/jenkins_home \
-v /etc/localtime:/etc/localtime \
--restart=always   \
--name jenkins jenkins

目录授权

sudo chown -R 1000:1000 /usr/local/docker/jenkins

3.Portainer可视化Docker管理容器

# 搜索镜像
docker search portainer/portainer
# 拉取镜像
docker pull portainer/portainer

docker run -d \
-p 9000:9000  \
-v /usr/local/docker/portainer:/data   \
-v /var/run/docker.sock:/var/run/docker.sock    \
-v /etc/localtime:/etc/localtime \
--restart=always    \
--name xwder-portainer portainer/portainer

4.RabbitMQ安装

docker run -d --name xwder-rabbitmq -p 5672:5672 -p 15672:15672  \
-v /usr/local/docker/rabbitmq/data:/var/lib/rabbitmq -v /etc/localtime:/etc/localtime  \
--hostname localhost --restart=always -e RABBITMQ_DEFAULT_VHOST=xwder  -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=q77ZA9NxKQHIDV7c rabbitmq:management

问题:启动容器后需要 进入容器开启插件才能web访问

docker exec -it xwder-rabbitmq bash
rabbitmq-plugins enable rabbitmq_management

5.nextcloud私有云盘安装

docker run  -d  \
-p 7002:80  \
-v /usr/local/docker/nextcloud:/var/www/html \
-v /etc/localtime:/etc/localtime \
--restart=always   \
--name xwder-nextcloud \
nextcloud

6.MySQL安装

首先准备配置文件到挂载的文件目录 /usr/local/docker/mysql/conf/my.cnf

[mysql]

#设置mysql客户端默认字符集
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
[mysqld]
#mysql5.7以后的不兼容问题处理
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

#允许最大连接数
max_connections=200
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8mb4
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M 
#设置时区
#default-time_zone='+8:00'
[mysqld_safe]
log-error=/var/log/mysqldb/mysqldb.log
pid-file=/var/run/mysqldb/mysqldb.pid
#
# include all files from the config directory
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

安装命令:

docker run --name xwder-mysql -p 3306:3306 \
--privileged=true --restart=always \
-d -v /usr/local/docker/mysql/logs:/logs \
-v /usr/local/docker/mysql/data:/var/lib/mysql \
-v /usr/local/docker/mysql/conf/my.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf \
-v /etc/localtime:/etc/localtime \
-e MYSQL_ROOT_PASSWORD=root mysql:5.7

7.elasticsearch 单机安装

docker run --name xwder-elasticsearch \
--privileged=true --restart=always \
-v /etc/localtime:/etc/localtime \
-d \
-p 9200:9200 -p 9300:9300 -e "discovery.type=single-es"  elasticsearch

8.minio私有OSS对象存储服务安装

ocker run -d -p 9018:9000 \
  --name xwder-minio \
  --restart=always   \
  -e "MINIO_ACCESS_KEY=bOf4fJPqwrUUmnXFPReCUAQ8GagcYqi0"  \
  -e "MINIO_SECRET_KEY=RBKufZsLEqSkg4Q3bUflrNko8OLXLaTntgGDXyE41AURFhUBKnkYYJ7ilGCDBcLt" \
  -v /usr/local/docker/minio/data:/data \
  -v /usr/local/docker/minio/config:/root/.minio \
  -v /etc/localtime:/etc/localtime \
  minio/minio server /data

9.Gogs Git服务器安装

docker run -d  \
-p 10022:22 -p 3000:3000 \
--restart=always \
--name=xwder-gogs \
-v /usr/local/docker/gogs:/data \
-v /etc/localtime:/etc/localtime gogs/gogs

10.MongoDB安装

docker run -d  \
-p 10022:22 -p 3000:3000 \
--restart=always \
--name=xwder-gogs \
-v /usr/local/docker/gogs:/data \
-v /etc/localtime:/etc/localtime gogs/gogs

安装后进入容器创建用户:
docker exec -it xwder-mongodb mongo admin
db.createUser({ user: 'xwder', pwd: 'EMlod4eZAFqVxF0M', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });

10.Oracle11g数据库安装

docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

docker start oracle11g

docker exec -it oracle11g bash

su root 
密码: helowin

vi /etc/profile
末尾追加:
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

source /etc/profile

ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

切换oracle用户:
su - oracle

登录oracle. 修改sys、system用户密码–创建用户:
# 登录
sqlplus /nolog   
# 连接
conn /as sysdba  
# 修改system用户账号密码;
alter user system identified by 密码;
# 修改sys用户账号密码;
alter user sys identified by 密码;
#创建内部管理员账号密码;
create user xwder identified by 密码; 
#将dba权限授权给内部管理员账号和密码;
grant connect,resource,dba to xwder; 
#修改密码规则策略为密码永不过期;(会出现坑,后面讲解)
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED; 
#修改数据库最大连接数据;
alter system set processes=1000 scope=spfile; 

连接数据库时候选择  sid 服务名称:helowin

11.Nacos安装

  • 不使用数据库安装:
docker run -d  --name xwder-nacos --privileged=true  -p 8848:8848 --env MODE=standalone --net host nacos/nacos-server
  • 使用数据库安装:

1、拉取镜像

docker pull nacos/nacos-server

2、配置文件custom.properties:

server.contextPath=/nacos
server.servlet.contextPath=/nacos
server.port=8848

spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://172.17.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=nacos
db.password=4GIRcSkjwE6Plf2D

nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i
nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**
nacos.naming.distro.taskDispatchThreadCount=1
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.naming.expireInstance=true

3、配置数据库

数据库脚本地址:https://github.com/alibaba/nacos/blob/master/config/src/main/resources/META-INF/nacos-db.sql

4、启动容器:

docker  run \
--name xwder-nacos -d \
-p 8848:8848 \
--privileged=true \
--restart=always \
-e JVM_XMS=256m \
-e JVM_XMX=256m \
-e MODE=standalone \
-e PREFER_HOST_MODE=hostname \
-v /usr/local/docker/nacos/logs:/etc/nacos/logs \
-v /usr/local/docker/nacos/init.d/custom.properties:/etc/nacos/init.d/custom.properties \
nacos/nacos-server

12.MongoDB安装

docker run -d  \
-p 10022:22 -p 3000:3000 \
--restart=always \
--name=xwder-gogs \
-v /usr/local/docker/gogs:/data \
-v /etc/localtime:/etc/localtime gogs/gogs

安装后进入容器创建用户:
docker exec -it xwder-mongodb mongo admin
db.createUser({ user: 'xwder', pwd: 'EMlod4eZAFqVxF0M', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });

13.SqlServer2017 服务器安装

docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=初始化sa用户的密码' \
-e 'MSSQL_PID=Developer' \
-p 1433:1433 -v /usr/local/docker/mssql:/var/opt/mssql \
--nam