- 应用docker容器启动jenkins
docker run -d -u root --name jenkins-ser01 --restart=always -p 80:8080 -p 50000:50000 -v /data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean
须要留神:
- /data 是宿主机的数据目录,请选用容量足够、性能好的文件系统
- 必须显示申明-u root,应用root启动容器,否则容器不能失常启动
- 宿主机的/var/run/docker.sock请确保存在,或请确保门路是正确的
- 拜访 http://192.168.11.252/login?f...
- 解锁Jenkins 对应宿主机上的数据门路是/data/secrets/initialAdminPassword
[root@svr-jenkins ~]# cat /data/secrets/initialAdminPassword bb7b64bf187048f1b7850208e9a2d9a4
将bb7b64bf187048f1b7850208e9a2d9a4复制到解锁页面进行解锁,而后下一步
- 首次插件装置
- 装置倡议的插件:装置举荐的一组插件,这些插件基于最常见的用例.
- 抉择要装置的插件:抉择装置的插件集。当你第一次拜访插件抉择页面时,默认抉择倡议的插件。
小白能够抉择装置倡议的插件,老司机能够抉择抉择要装置的插件
如果总是有装置失败的插件,可先点击持续跳过,后续再切换下载源地址,再进行装置
- 持续接下来的步骤 创立治理账号
而后抉择保留并实现持续
实例配置,能够放弃默认
而后抉择保留并实现持续
最初抉择重启
点击了重启后,发现容器进行了,拉起即可。
- 拉起容器jenkins-ser01
[root@svr-jenkins ~]# docker start jenkins-ser01jenkins-ser01[root@svr-jenkins ~]#
提醒!启动容器时,能够加上 --restart=always,当容器stop掉的时候会主动拉起容器
最初,即可胜利进入到登录页面!用创立好的第一个管理员账号登录即可
Harbor官方网站:http://vmware.github.io/harbor/ Harbor
源码地址:https://github.com/vmware/harbor
硬件要求:
- 最低要求 2c/4m/40g
- 举荐 4c/8m/160g
Harbor所需软件:
- vmware harbor (镜像仓库)
- docker ce (docker容器引擎,社区版)
- docker compose (批量治理容器,高效治理主机上的docker容器)
装置形式
- 在线装置
- 离线装置(本文次要简略解说离线装置的全过程,应用docker-compose的形式装置)
开始离线装置
- 下载harbor离线包
wget https://github.com/goharbor/harbor/releases/download/v2.6.2/harbor-offline-installer-v2.6.2.tgz
- 装置最新版本的Docker Engine、containerd和Docker Compose
yum install -y yum-utils device-mapper-persistent-data lvm2yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.reposed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repoyum makecache fastyum install docker-ce docker-compose-plugin -yln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/
- 解压
[root@svr-harbor ~]# tar -zxf harbor-offline-installer-v2.6.2.tgz[root@svr-harbor ~]# cd harbor[root@svr-harbor harbor]#
- 批改上面2处配置,在这里,为了简略不便,其余配置放弃默认
[root@svr-harbor ~]# cd harbor[root@svr-harbor harbor]# cp -a harbor.yml.tmpl harbor.yml[root@svr-harbor harbor]# egrep -v "#|^$" harbor.yml# 内容如下:hostname: 192.168.11.250http: port: 80data_volume: /data
数据目录请抉择容量足够、性能好的文件系统
- 正文掉harbor.yml中和https无关的配置(内网就不配置https了)
#https:# port: 443# certificate: /your/certificate/path# private_key: /your/private/key/path
- 开始初始化
[root@svr-harbor harbor]# ./prepare
- 执行装置脚本
[root@svr-harbor harbor]# ./install.sh
留神:亲测,请确保防火墙是关上的状态,因为在install的过程中会主动配置防火墙策略,如果防火墙是进行的,将会install失败。装置胜利后,最初会提醒:Harbor has been installed and started successfully.----
- 查看数据目录
[root@svr-harbor ~]# cd /data/[root@svr-harbor data]# lsca_download database job_logs redis registry scandata_exports secret[root@svr-harbor data]#
装置实现后,曾经在指定的数据目录下主动创立了所需的目录,这就是保留任何数据的目录
- 查看运行的容器
[root@svr-harbor ~]# cd harbor[root@svr-harbor harbor]# docker-compose psNAME COMMAND SERVICE STATUS PORTSharbor-core "/harbor/entrypoint.…" core running (healthy) harbor-db "/docker-entrypoint.…" postgresql running (healthy) harbor-jobservice "/harbor/entrypoint.…" jobservice running (healthy) harbor-log "/bin/sh -c /usr/loc…" log running (healthy) 127.0.0.1:1514->10514/tcpharbor-portal "nginx -g 'daemon of…" portal running (healthy) nginx "nginx -g 'daemon of…" proxy running (healthy) 0.0.0.0:80->8080/tcp, :::80->8080/tcpredis "redis-server /etc/r…" redis running (healthy) registry "/home/harbor/entryp…" registry running (healthy) registryctl "/home/harbor/start.…" registryctl running (healthy) [root@svr-harbor harbor]#
留神要进去harbor目录下,须要在docker-compose.yml配置文件所在的目录下能力正确执行docker compose命令
- 拜访
拜访80端口即可拜访到UI,默认的账号是admin,默认的明码是Harbor12345
- 罕用治理
# 进行[root@svr-harbor harbor]# docker-compose stop# 查看运行的容器[root@svr-harbor harbor]# docker-compose ps# 启动[root@svr-harbor harbor]# docker-compose up -d# 或者这样启动[root@svr-harbor harbor]# docker-compose start
镜像的推送和拉取
在另外一台装置有docker的主机上推送镜像到harbor仓库
在/etc/docker/daemon.json配置文件下减少insecure-registries配置,这个操作应该就是注册受信赖的仓库地址,容许往这个仓库进行推送镜像,否则就会回绝。
{ "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"], "insecure-registries": ["192.168.11.250"] //这是减少的}
留神,这是一个json格局的配置文件,现有的配置不要动,减少即可,如果须要注册多个,在数组里用逗号分隔增加就好。
重启docker服务
[root@test-a-docker01 ~]# systemctl daemon-reload[root@test-a-docker01 ~]# systemctl restart docker
我本地有个nginx的镜像,将其打标签,它是通过标签的形式来得悉属于哪个仓库、哪个我的项目
[root@test-a-docker01 ~]# docker tag nginx:latest 192.168.11.250/library/nginx:v1
- 192.168.11.250是仓库服务器的IP地址
- library是harbor服务器上的我的项目文件夹
登录
[root@test-a-docker01 ~]# docker login 192.168.11.250Username: adminPassword: WARNING! Your password will be stored unencrypted in /root/.docker/config.json.Configure a credential helper to remove this warning. Seehttps://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded
推送
[root@test-a-docker01 ~]# docker push 192.168.11.250/library/nginx:v1
拉取
# 先删除本地的(为了测试)[root@test-a-docker01 ~]# docker rmi 192.168.11.250/library/nginx:v1# 再拉取[root@test-a-docker01 ~]# docker pull 192.168.11.250/library/nginx:v1v1: Pulling from library/nginxDigest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3Status: Downloaded newer image for 192.168.11.250/library/nginx:v1192.168.11.250/library/nginx:v1[root@test-a-docker01 ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEbusybox latest beae173ccac6 10 months ago 1.24MB192.168.11.250/library/nginx v1 605c77e624dd 10 months ago 141MBnginx latest 605c77e624dd 10 months ago 141MBgolang latest 276895edf967 11 months ago 941MBcentos latest 5d0da3dc9764 14 months ago 231MB[root@test-a-docker01 ~]#
Gitlab所需软件
- docker ce
- docker compose
在centos7上装置docker-ce(社区版),装置最新版本的Docker Engine、containerd和Docker Compose
# 装置所需的零碎工具sudo yum install -y yum-utils device-mapper-persistent-data lvm2# 增加软件源信息yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.reposed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo#更新并装置yum makecache fast[root@svr-harbor ~]# yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y[root@svr-harbor ~]# ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/# 启动Docker服务systemctl start docker
- 设置环境变量
[root@svr-gitlab ~]# echo "export GITLAB_HOME=/data" >> .bash_profile [root@svr-gitlab ~]# source .bash_profile
/data目录将会作为gitlab的数据目录,请抉择容量足够、性能好的文件系统
- 创立和配置docker-compose.yml
[root@svr-gitlab ~]# mkdir gitlab[root@svr-gitlab ~]# cd gitlab/[root@svr-gitlab gitlab]# vi docker-compose.yml
- docker-compose.yml的内容如下:
version: '3.6'services: web: image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'gitlab-ser' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'https://192.168.11.251' # Add any other gitlab.rb configuration here, each on its own line ports: - '443:443' volumes: - '$GITLAB_HOME/config:/etc/gitlab' - '$GITLAB_HOME/logs:/var/log/gitlab' - '$GITLAB_HOME/data:/var/opt/gitlab' shm_size: '256m'
[root@svr-gitlab gitlab]# docker compose up -d[+] Running 7/9 ⠼ web Pulling ... ... ...
确保启动的命令和docker-compose.yml位于同一目录中
- 首次启动需做各种初始化的动作,需多期待一会再拜访
https://192.168.11.251/users/...
首次登录时,明码是随机的,上面解说如何查看初始的明码,默认的账号是root
# 查看容器[root@svr-gitlab data]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES1427ade162cb gitlab/gitlab-ce:latest "/assets/wrapper" 11 minutes ago Up 9 minutes (healthy) 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:2222->22/tcp, :::2222->22/tcp gitlab-web-1# 进入容器[root@svr-gitlab gitlab]# docker exec -it gitlab-web-1 bash# 查看初始密码root@gitlab-ser:/# cat /etc/gitlab/initial_root_password # WARNING: This value is valid only in the following conditions# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).# 2. Password hasn't been changed manually, either via UI or via command line.## If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.Password: 1auf23re9a70Tikipx9edUzICyLPuYwkMoHmV+QY8cs=# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
明码就是这个:1auf23re9a70Tikipx9edUzICyLPuYwkMoHmV+QY8cs=
正告!应用初始密码登录后,记得尽快重置root的明码,因为在24小时后,将会主动删除掉/etc/gitlab/initial_root_password文件
本文转载于:https://mp.weixin.qq.com/s/D_...