Centos7下安装Docker

1,root账户登录,查看内核版本

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

2,把yum包更新到最新(期间要选择确认,输入 y 即可)

[root@localhost ~]# yum update
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务

3,安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
软件包 device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 已安装并且是最新版本
软件包 7:lvm2-2.02.187-6.el7_9.5.x86_64 已安装并且是最新版本
无须任何处理

4,设置yum源(选择其中一个)

yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo(中央仓库)

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo(阿里仓库)
[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

5,可以查看所有仓库中所有docker版本,并选择特定版本安装

[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror, langpacks
可安装的软件包
 * updates: mirrors.163.com
Loading mirror speeds from cached hostfile
 * extras: mirrors.163.com
docker-ce.x86_64            3:20.10.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.15-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.14-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.13-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.12-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.11-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.10-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64            18.06.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.3.ce-1.el7                    docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable
 * base: mirrors.163.com

6,安装Docker,命令:yum install docker-ce-版本号,我选的是docker-ce-18.06.2.ce,如下(期间要选择确认,输入 y 即可),如果centos8报错则运行rpm -q podman & yum erase podman buildah后再运行yum install docker-ce docker-ce-cli containerd.io

[root@localhost ~]# yum install docker-ce-18.06.2.ce
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.0.18.06.2.ce-3.el7 将被 安装
--> 正在处理依赖关系 container-selinux >= 2.9,它被软件包 docker-ce-18.06.2.ce-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装
--> 解决依赖关系完成

依赖关系解决

=============================================================================================================================================================================================
 Package                                       架构                               版本                                                    源                                            大小
=============================================================================================================================================================================================
正在安装:
 docker-ce                                     x86_64                             18.06.2.ce-3.el7                                        docker-ce-stable                              41 M
为依赖而安装:
 container-selinux                             noarch                             2:2.119.2-1.911c772.el7_8                               extras                                        40 k

事务概要
=============================================================================================================================================================================================
安装  1 软件包 (+1 依赖软件包)

总下载量:41 M
安装大小:168 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                                                                           |  40 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.06.2.ce-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY   ] 8.0 MB/s |  38 MB  00:00:00 ETA 
docker-ce-18.06.2.ce-3.el7.x86_64.rpm 的公钥尚未安装
(2/2): docker-ce-18.06.2.ce-3.el7.x86_64.rpm                                                                                                                          |  41 MB  00:00:04     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                          10 MB/s |  41 MB  00:00:04     
从 https://mirrors.aliyun.com/docker-ce/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
 用户ID     : "Docker Release (CE rpm) <docker@docker.com>"
 指纹       : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 来自       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                       1/2 
  正在安装    : docker-ce-18.06.2.ce-3.el7.x86_64                                                                                                                                        2/2 
  验证中      : docker-ce-18.06.2.ce-3.el7.x86_64                                                                                                                                        1/2 
  验证中      : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                       2/2 

已安装:
  docker-ce.x86_64 0:18.06.2.ce-3.el7                                                                                                                                                        

作为依赖被安装:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8                                                                                                                                         

完毕!

7, 启动Docker,命令:systemctl start docker,如下

[root@localhost ~]# systemctl start docker
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

8,然后加入开机启动 systemctl enable docker,如下

[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

8,配置docker阿里云的镜像加速,如下

[root@localhost docker]# pwd
/etc/docker
[root@localhost docker]# touch daemon.json
[root@localhost docker]# ls
daemon.json  key.json
[root@localhost docker]# vim daemon.json 
{
  "registry-mirrors": ["https://nddtcun9.mirror.aliyuncs.com"]
}

9,重新加载配置(sudo systemctl daemon-reload ) 重启docker  (sudo systemctl restart docker)

[root@localhost docker]# systemctl daemon-reload
[root@localhost docker]# systemctl restart docker

windwos启动rockermq

1、start mqnamesrv.cmd
2、start mqbroker.cmd -n 127.0.0.1:9876 autoCreateTopicEnable=true

启动redis哨兵

docker run -it \
--privileged=true \
-p 6384:6384 \
-v /data/redis/redis6384/config/redis.conf:/etc/redis/redis.conf \
-v /data/redis/redis6384/data:/data \
--name redis6384 \
-w=/etc/redis/ \
redis:latest \
redis-server /etc/redis/redis.conf --sentinel

启动mq nameserv

docker run -d -p 9876:9876 -v `pwd`/data/namesrv/logs:/root/logs -v `pwd`/data/namesrv/store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:4.4.0 sh mqnamesrv

启动mq broker

docker run -d -p 10911:10911 -p 10909:10909 -v `pwd`/data/broker/logs:/root/logs -v `pwd`/data/broker/store:/root/store --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:4.4.0 sh mqbroker

启动mq监控程序

docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=172.17.0.8:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8080:8080 -t styletang/rocketmq-console-ng

启动seafile

docker run -d --name seafile \
  -e SEAFILE_SERVER_HOSTNAME=ip \
  -v /data/seafile:/shared  \
  -p 8000:8000 \
  -p 8082:8082 \
  -e SEAFILE_ADMIN_EMAIL="123@qq.com" \
  -e SEAFILE_ADMIN_PASSWORD="123" \
   seafileltd/seafile

启动nacos

application.properties 配置文件如下:

# spring
server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
server.contextPath=/nacos
server.port=${NACOS_SERVER_PORT:8848}
spring.datasource.platform=${SPRING_DATASOURCE_PLATFORM:""}
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
db.num=${MYSQL_DATABASE_NUM:1}
db.url.0=jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT:3306}/${MYSQL_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.url.1=jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT:3306}/${MYSQL_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=${MYSQL_SERVICE_USER}
db.password=${MYSQL_SERVICE_PASSWORD}
### The auth system to use, currently only 'nacos' is supported:
nacos.core.auth.system.type=${NACOS_AUTH_SYSTEM_TYPE:nacos}


### The token expiration in seconds:
nacos.core.auth.default.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000}

### The default token:
nacos.core.auth.default.token.secret.key=${NACOS_AUTH_TOKEN:SecretKey012345678901234567890123456789012345678901234567890123456789}

### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
nacos.core.auth.caching.enabled=${NACOS_AUTH_CACHE_ENABLE:false}

server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
# default current work dir
server.tomcat.basedir=
## spring security config
### turn off security
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
# metrics for elastic search
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false

nacos.naming.distro.taskDispatchThreadCount=10
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
docker run -d -p 8848:8848  \
-e MODE=standalone \
-e PREFER_HOST_MODE=hostname \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_SERVICE_HOST=192.168.154.128 \
-e MYSQL_SERVICE_PORT=3306 \
-e MYSQL_SERVICE_DB_NAME=nacos_config \
-e MYSQL_SERVICE_USER=root \
-e MYSQL_SERVICE_PASSWORD=root \
-e MYSQL_DATABASE_NUM=1 \
-v /data/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \
-v /data/nacos/logs:/home/nacos/logs \
--restart always --name nacos nacos/nacos-server


docker run --name nacos -d -p 8848:8848 
--privileged=true --restart=always 
-e JVM_XMS=256m 
-e JVM_XMX=256m 
-e SPRING_DATASOURCE_PLATFORM=mysql 
-e MYSQL_SERVICE_HOST=192.168.31.10
-e MYSQL_SERVICE_PORT=3306 
-e MYSQL_SERVICE_DB_NAME=nacos_config
-e MYSQL_SERVICE_USER=root 
-e MYSQL_SERVICE_PASSWORD=root 
-v /data/nacos/logs:/data/software/nacos-docker/logs 
-v /data/nacos/init.d/custom.properties:/data/software/nacos-docker/init.d/custom.properties 
nacos/nacos-server

启动mysql

docker run  -p 3306:3306  --name mysql5.7  -v /data/mysql5.7/conf:/etc/mysql/mysql.conf.d -v /data/mysql5.7/logs:/var/log/mysql  -v /data/mysql5.7/data:/var/lib/mysql  -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7

启动gitlab

docker run -it -p 7080:80 -p 2222:22 \
--name gitlab \
--restart always \
--volume /data/gitlab/config:/etc/gitlab \
--volume /data/gitlab/logs:/var/log/gitlab \
--volume /data/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest

启动jenkins

sudo docker run -d -p 8099:8080 -v /data/jenkins:/var/jenkins_home --name jenkins jenkins:latest

修改jenkins插件镜像地址
sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json

oracle操作

切换到image的oracle用户   su - oracle
进入oracle数据库           sqlplus / as sysdba
进入oracle控制台,并输入conn /as sysdba;以DBA角色进入。

system默认:manager
sys默认:change_on_install
使用SQL Plus登录数据库时,system使用密码manager可直接登录。
但如果是sys用户,密码必须加上as sysdba,即完整密码为:change_on_install as sysdba

连接成功后,输入“select username from dba_users”查看用户列表。

分配DBA权限
grant connect, resource, dba to FSMC_TEST;
若修改某一个用户密码, 修改用户口令,格式为:
alter user 用户名 identified by 新密码;

1、 创建表空间
create tablespace FSMC_TEST datafile 'FSMC_TEST.dbf' size 100m autoextend on next 10m;
2、创建用户
create user FSMC_TEST identified by 123456 default tablespace FSMC_TEST;
3、给用户授权限
grant dba to FSMC_TEST;

Linux命令

--开发端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent
--查看端口是否开放
firewall-cmd --query-port=80/tcp
--重启防火墙
firewall-cmd --reload

查看docker中运行镜像的启动命令方法

一、安装pip
1:wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
2:python get-pip.py

二、使用pip安装runlike服务
3:sudo pip install runlike

三、使用runlike查看docker镜像运行命令
4:runlike -p redis(镜像名称或ID)