从零开始的Devops-软件源
从零开始的Devops-软件源
内网办公
其实如果不是内网办公,软件源直接用阿里云的,官方的就好。奈何内网办公。内网办公公司不开放公网给项目组成员,必须要搭建本地仓库,使用本地仓库减少向公网的访问次数,相同的软件依赖包不用多次下载,比如大家都使用Java的maven依赖,如果没有本地仓库,每次都要去maven center下载。都使用npm的话,每次下载其他的package也都要从npm官网下载。目前都是用u盘从外网拷入,时常会发生恶意软件感染与软件来源不可控的问题。无软件基线
nexus 仓库
软件源搭建
软件源建设路线
nexus搭建docker镜像仓库
docker search nexus
docker pull sonatype/nexus3
mkdir -p /data/nexus-data
chmod -R 777 /data/nexus-data
docker run -d -p 4995-4998:8081-8084 --name nexus3 -v /data/nexus-data:/nexus-data --restart=always sonatype/nexus3
docker stop nexus3 |xargs docker rm
docker stop nexus |xargs docker rm
docker logs -f nexus3
netstat -an | grep 4995
nexus docker如何配置私仓
nexus添加docker blob
nexus添加docker Registry hosted
nexus添加docker realm认证
上传镜像
登录仓库
docker login -u admin -p admin123 172.16.77.71:8082 #注意这里的端口是配置仓库时选择的端口号
上传镜像
docker tag nginx:latest 172.16.77.71:8082/nginx:0.1
docker push 172.16.77.71:8082/nginx:0.1
拉取镜像
docker pull 172.16.77.71:8082/nginx:0.1
搜索镜像
[root@k8s-77-40 torch]# docker search 172.16.77.71:8082/nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
172.16.77.71:8082/nginx:0.1 0
总结
到此,使用nexus搭建的docker私有仓库配置完毕。公司常用的镜像可以存放在私有仓库里
nginx搭建yum
启动nginx,主要是为了获取配置文件
启动nginx
docker run --name nginx -d -p 80:80 nginx
通过浏览器访问 http://IP,出现【Welcome to nginx!】表示成功
拷贝默认配置文件
sudo mkdir /etc/nginx
cd /etc/nginx/
sudo docker cp nginx:/etc/nginx/nginx.conf /etc/nginx/nginx.conf
sudo docker cp nginx:/etc/nginx/conf.d/ /etc/nginx/conf.d
配置文件拷贝完成,停止当前nginx,使用外部配置文件启动
停止并删除当前nginx服务
sudo docker stop nginx
sudo docker rm nginx
新建日志文件夹
sudo mkdir /etc/nginx/log
启动nginx
sudo docker run --name nginx \
-d -p 80:80 -v /data/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /data/nginx/conf.d/:/etc/nginx/conf.d/ \
-v /data/nginx/log:/var/log/nginx \
-v /data/nginx/html/:/usr/share/nginx/html/ \
-v /data/nginx/home/:/home/ \
nginx
执行以下命令查看nginx服务
sudo docker ps
挂载suse软件源
lsb_release -d
查看版本号
https://blog.csdn.net/hanzheng260561728/article/details/52181590/
https://my.oschina.net/vright/blog/1858836
https://blog.csdn.net/qq_35180983/article/details/82490613
nginx搭建suse
https://msd.misuland.com/pd/3148108429789234124
为啥docker nginx需要docker cp?
因为没有需要的nginx.conf文件
因为没有需要的/con.d/default.conf文件
user nginx; #设置nginx服务的系统使用用户
worker_processes 1; #工作进程数
error_log /var/log/nginx/error.log warn; #nginx的错误日志
pid /var/run/nginx.pid; #nginx启动时候的pid
events {
worker_connections 1024; #每个进程允许的最大连接数
}
http { #http请求配置,一个http可以包含多个server
#定义 Content-Type
include /etc/nginx/mime.types;
default_type application/octet-stream;
#日志格式 此处main与access_log中的main对应
#$remote_addr:客户端地址
#$remote_user:http客户端请求nginx认证的用户名,默认不开启认证模块,不会记录
#$timelocal:nginx的时间
#$request:请求method + 路由 + http协议版本
#status:http reponse 状态码
#body_bytes_sent:response body的大小
#$http_referer:referer头信息参数,表示上级页面
#$http_user_agent:user-agent头信息参数,客户端信息
#$http_x_forwarded_for:x-forwarded-for头信息参数
log_format main '$http_user_agent' '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#访问日志,后面的main表示使用log_format中的main格式记录到access.log中
access_log /var/log/nginx/access.log main;
#nginx的一大优势,高效率文件传输
sendfile on;
#tcp_nopush on;
#客户端与服务端的超时时间,单位秒
keepalive_timeout 65;
#gzip on;
server { #http服务,一个server可以配置多个location
listen 80; #服务监听端口
server_name localhost; #主机名、域名
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html; #页面存放目录
index index.html index.htm; #默认页面
}
#error_page 404 /404.html;
# 将500 502 503 504的错误页面重定向到 /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html { #匹配error_page指定的页面路径
root /usr/share/nginx/html; #页面存放的目录
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
include /etc/nginx/conf.d/*.conf;
}

浙公网安备 33010602011771号