docker安装jenkins

1.拉取镜像

命令
1
docker pull jenkins/jenkins:latest

2.构建shell

命令
1
2
3
4
5
docker run -d -u root -p 你的端口:8080 \
-v /home/ubuntu/docker-v/toolJenkins/jenkinsHome:/var/jenkins_home \
--restart=always \
--name toolJenkins \
jenkins/jenkins:latest

3.配置镜像

3.1修改hudson.model.UpdateCenter.xml配置文件

命令
1
2
3
4
5
6
sudo vim /home/ubuntu/docker-v/toolJenkins/jenkinsHome/hudson.model.UpdateCenter.xml

默认路径
http://updates.jenkins-ci.org/update-center.json
改成路径
http://mirror.xmission.com/jenkins/updates/update-center.json

3.2修改default.json配置文件

命令
1
2
3
4
5
6
sudo vim /home/ubuntu/docker-v/toolJenkins/jenkinsHome/updates/default.json

默认路径
"connectionCheckUrl":"http://www.google.com/"
改为路径
"connectionCheckUrl":"http://www.baidu.com/"

docker安装nginx

1.拉取镜像

命令
1
docker pull nginx:latest

2.运行shell

命令
1
docker run --name service-nginx -p 8084:80 -d nginx

p映射端口
d后台运行
v挂在目录,可以根据需求自行设置


ps:根据自定义配置

1.创建配置文件

命令
1
1. vim /home/jmlib/docker-v/serviceNginx/nginx.conf

2.配置详情

配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
user  nginx;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*/*.conf;
}

3.构建shell命令

服务
1
2
3
4
5
6
7
8
9
10
11
docker run -d \
--restart=always \
-p 8084:8084 \
-p 8085:8085 \
-p 8086:8086 \
-p 8087:8087 \
-p 2192:2192 \
-v /home/jmlib/docker-v/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /home/jmlib/docker-v/nginx/conf.d:/etc/nginx/conf.d \
-v /home/jmlib/docker-v/nginx/www:/etc/nginx/www \
--name nginx nginx
公司服务
1
2
3
4
5
6
7
docker run -d \
-p 80:80 \
-v /Users/lizihan/Desktop/docker-v/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /Users/lizihan/Desktop/docker-v/nginx/conf.d:/etc/nginx/conf.d \
-v /Users/lizihan/Desktop/docker-v/nginx/www:/etc/nginx/www/lizihan \
-v /Volumes/研发部代码/nginx/www:/etc/nginx/www/company \
--name nginx-company nginx

常用配置

nginx转发端口
1
2
3
4
5
6
7
8
server{
listen 80;
server_name test.sakikun.com;

location / {
proxy_pass http://61.153.125.171/:2189; # 转发规则
}
}
nginx转发端口 ssl认证
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server{
listen 443;
server_name steam30off.sakikun.com;
ssl on;
#从腾讯云获取到的第一个文件的全路径
ssl_certificate /etc/nginx/conf.d/key/1_steam30off.sakikun.com_bundle.crt;
#从腾讯云获取到的第二个文件的全路径
ssl_certificate_key /etc/nginx/conf.d/key/2_steam30off.sakikun.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:2191; # 转发规则
}
}

ubuntu20.04 LTS安装docker

1.卸载旧版docker

命令
1
sudo apt-get remove docker docker-engine docker.io

2.更新系统软件

命令
1
sudo apt-get update

3.安装依赖包

命令
1
2
3
4
5
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common

4.配置阿里云密钥

命令
1
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

如出现:gpg: can’t connect to the agent: IPC connect call failed 这种问题,可以尝试:
1.sudo apt remove gpg
2.sudo apt install gnupg1
3.在执行 curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

5.配置阿里云docker镜像

命令
1
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

6.执行安装

命令
1
sudo apt-get install docker-ce docker-ce-cli containerd.io

PS:用户组配置

docker ps -a 出现
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json?all=1: dial unix /var/run/docker.sock: connect: permission denied
sudo groupadd docker

命令
1
2
3
4
5
sudo groupadd docker #添加docker用户组

sudo gpasswd -a $USER docker #将登陆用户加入到docker用户组中

newgrp docker #更新用户组

docker安装mysql

1.拉取镜像

docker pull mysql:8.0

2.创建数据目录和配置文件

本地
1
2
3
mkdir /home/jmlib/docker-v/mysql8/data

mkdir /home/jmlib/docker-v/mysql8/cnf

3.创建配置文件

本地
1
vim /home/jmlib/docker-v/mysql8/data/my.cnf
服务
1
vim /home/jmlib/docker-v/mysql8/data/my.cnf
配置详情
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[client]

default-character-set = utf8mb4

[mysqld]

datadir = /usr/mysql/data

character_set_server = utf8mb4

collation_server = utf8mb4_bin

secure-file-priv= NULL

symbolic-links=0

!includedir /etc/mysql/conf.d/

4.启动容器

本地
1
2
3
4
5
docker run -d  -p 3306:3306 \
-v /home/jmlib/docker-v/mysql8/data/my.cnf:/etc/mysql/my.cnf \
--restart=unless-stopped \
-e MYSQL_ROOT_PASSWORD=123456 \
--name mysql mysql:8.0
服务
1
2
3
4
5
6
7
docker run -d  -p 3306:3306 \
-v /home/jmlib/docker-v/mysql8/cnf/my.cnf:/etc/mysql/conf.d/my.cnf \
-v /home/jmlib/docker-v/mysql8/data:/var/lib/mysql \
-v /home/jmlib/docker-v/mysql8/home:/home \
--restart=always \
-e MYSQL_ROOT_PASSWORD=123456 \
--name mysql mysql:8.0

5.mysql初始化

初始化详情
1
2
3
4
5
docker exec -it mysql bash
mysql -uroot -p
use mysql
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'yiluxiangbei';
flush privileges;
SwiftUI解决隐藏NavigationBar后返回失效

SwiftUI解决隐藏NavigationBar后返回失效

获取小键盘高度

@ObservedObject private var keyboard = KeyboardResponder()
keyboard.currentHeight

通过小键盘高度判断是否需要添加灰色背景,点击灰色背景隐藏小键盘
1
2
3
4
5
6
7
8
9
10
11
12
13
14
if keyboard.currentHeight != 0 {
Color.gray
.edgesIgnoringSafeArea(.all)
.opacity(0.4)
.onTapGesture {
withAnimation(.spring()){
UIApplication.shared.windows.forEach { (window) in
if window.isKeyWindow {
window.endEditing(true)
}
}
}
}
}

效果图

keyboardhandle.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import UIKit
import Foundation
import SwiftUI
import Combine
class KeyboardResponder: ObservableObject {
private var _center: NotificationCenter
@Published var currentHeight: CGFloat = 0

init(center: NotificationCenter = .default) {
_center = center
_center.addObserver(self, selector: #selector(keyBoardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
_center.addObserver(self, selector: #selector(keyBoardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}

deinit {
_center.removeObserver(self)
}

@objc func keyBoardWillShow(notification: Notification) {
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
currentHeight = keyboardSize.height
}
}

@objc func keyBoardWillHide(notification: Notification) {
currentHeight = 0
}
}

class KeyboardHeightHelper: ObservableObject {
@Published var keyboardHeight: CGFloat = 0

init() {
self.listenForKeyboardNotifications()
}
private func listenForKeyboardNotifications() {
NotificationCenter.default.addObserver(forName: UIResponder.keyboardDidShowNotification,
object: nil,
queue: .main) { (notification) in
guard let userInfo = notification.userInfo,
let keyboardRect = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
self.keyboardHeight = keyboardRect.height
}

NotificationCenter.default.addObserver(forName: UIResponder.keyboardDidHideNotification,
object: nil,
queue: .main) { (notification) in
self.keyboardHeight = 0
}
}
}
node升级降级

node升级降级

(1)安装node版本管理模块n

命令
1
sudo npm install n -g

(2.1)安装稳定版

命令
1
sudo n stable

(2.2)安装最新版

命令
1
sudo n latest

(2.3) 版本降级/升级

命令
1
sudo n 版本号//例如:sudo n 9.1.7

————————————————
版权声明:本文为CSDN博主「姜无忧」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xiasohuai/article/details/92995717


:D 一言句子获取中...