文章目录

Docker常用容器安装

Docker 命令参数说明:

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

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" } ] });