文章目录terminator 美化 Draculagit 代理设置Docker代理设置Docker 代理分为两种场景场景 1配置 Docker Daemon 代理拉取镜像用场景 2配置容器内代理容器运行时用方式 1运行容器时临时指定单次生效方式 2全局配置容器代理所有容器生效代码片段python.jsomCpp.jsonterminator 美化 Dracula[global_config]inactive_color_offset0.61suppress_multiple_term_dialogTrue[keybindings][profiles][[default]]allow_boldFalse background_color#282a36background_imageNone fontAnonymous Pro12foreground_color#f8f8f2palette#262626:#e356a7:#42e66c:#e4f34a:#9b6bdf:#e64747:#75d7ec:#efa554:#7a7a7a:#ff79c6:#50fa7b:#f1fa8c:#bd93f9:#ff5555:#8be9fd:#ffb86c[layouts][[default]][[[child1]]]parentwindow0 typeTerminal[[[window0]]]parenttypeWindow[plugins]git 代理设置当前会话的设置functionset-proxy(){# 1. 设置终端全局代理curl/wget/apt 等命令生效exportHTTP_PROXYhttp://127.0.0.1:7890exportHTTPS_PROXYhttp://127.0.0.1:7890exportFTP_PROXYhttp://127.0.0.1:7890exportNO_PROXYlocalhost,127.0.0.1,192.168.0.0/16,172.17.0.0/16,*.local,*.docker.internal# 小写变量兼容部分只识别小写的程序exporthttp_proxy${HTTP_PROXY}exporthttps_proxy${HTTPS_PROXY}exportftp_proxy${FTP_PROXY}exportno_proxy${NO_PROXY}# 2. 设置 Git 代理仅当前会话生效非全局# 方式通过环境变量覆盖 Git 配置比 git config 更轻量会话结束自动失效exportGIT_HTTP_PROXY${HTTP_PROXY}exportGIT_HTTPS_PROXY${HTTPS_PROXY}# 提示信息echo-e\033[32m✅ 代理已设置仅当前终端生效\033[0mecho终端代理${HTTPS_PROXY}echoGit 代理${GIT_HTTPS_PROXY}}# 查看当前代理配置functioncheck-proxy(){echo-e\033[34m 当前终端代理配置\033[0mechoHTTP_PROXY:${HTTP_PROXY:-未设置}echoHTTPS_PROXY:${HTTPS_PROXY:-未设置}echo-e\033[34m 当前 Git 代理配置\033[0mechoGIT_HTTPS_PROXY:${GIT_HTTPS_PROXY:-未设置}# 额外查看 Git 全局/局部配置确认无残留gitconfig--global--gethttp.https://github.com.proxy2/dev/null||echoGit 全局代理未设置gitconfig--local--gethttp.https://github.com.proxy2/dev/null||echoGit 局部代理未设置}Docker代理设置Docker 代理分为两种场景Docker Daemon 代理用于拉取 / 推送镜像访问 Docker Hub、私有仓库 容器内代理用于容器运行时访问外部网络如容器内 curl、wget 走代理。场景 1配置 Docker Daemon 代理拉取镜像用修改 Docker 守护进程的配置文件步骤如下# 1. 创建 Docker 配置目录若不存在sudomkdir-p/etc/docker# 2. 编辑 daemon.json 文件核心配置sudovim/etc/docker/daemon.json{dns:[8.8.8.8,8.8.4.4],log-driver:json-file,log-opts:{max-file:3,max-size:10m},registry-mirrors:[https://dockerproxy.com,https://cr.console.aliyun.com,https://mirror.aliyuncs.com,https://docker.mirrors.ustc.edu.cn,https://hub-mirror.c.163.com,https://mirror.baidubce.com,https://docker.nju.edu.cn,https://docker.mirrors.sjtug.sjtu.edu.cn,https://docker.xuanyuan.me,https://docker.1ms.run,https://docker.m.daocloud.io,https://ccr.ccs.tencentyun.com,https://registry.docker-cn.com,https://docker.imgdb.de,https://docker-0.unsee.tech,https://docker.hlmirror.com,https://func.ink,https://lispy.org,https://docker.xiaogenban1993.com,https://2a6bf1988cb6428c877f723ec7530dbc.mirror.swr.myhuaweicloud.com,https://dockerhub.icu,https://docker.registry.cyou,https://docker-cf.registry.cyou,https://dockercf.jsdelivr.fyi,https://docker.jsdelivr.fyi,https://dockertest.jsdelivr.fyi,https://mirror.iscas.ac.cn,https://docker.rainbond.cc],runtimes:{nvidia:{args:[],path:nvidia-container-runtime}},storage-driver:overlay2,http-proxy:http://127.0.0.1:7890,https-proxy:http://127.0.0.1:7890,no-proxy:localhost,127.0.0.1,192.168.0.0/16,172.17.0.0/16,*.docker.internal}# 3. 重启 Docker 服务使配置生效sudosystemctl daemon-reloadsudosystemctl restartdocker# 4. 验证配置查看 Docker 信息确认代理已生效dockerinfo|grep-iproxy场景 2配置容器内代理容器运行时用方式 1运行容器时临时指定单次生效# 方式A通过环境变量指定dockerrun-it--rm\-eHTTP_PROXYhttp://127.0.0.1:7890\-eHTTPS_PROXYhttp://127.0.0.1:7890\-eNO_PROXYlocalhost,127.0.0.1\ubuntu:latest# 方式B若代理在主机需先获取主机内网 IP容器访问主机代理用# 查看主机内网 IP通常是 172.17.0.1ipaddr show docker0|grep-oP(?inet\s)\d(\.\d){3}# 容器内访问主机代理替换为实际 IPdockerrun-it--rm\-eHTTP_PROXYhttp://172.17.0.1:7890\ubuntu:latest方式 2全局配置容器代理所有容器生效创建容器默认的环境变量配置文件# 1. 创建配置目录sudomkdir-p/etc/systemd/system/docker.service.d# 2. 编辑 proxy.conf 文件sudovim/etc/systemd/system/docker.service.d/proxy.conf[Service]EnvironmentHTTP_PROXYhttp://127.0.0.1:7890/EnvironmentHTTPS_PROXYhttp://127.0.0.1:7890/EnvironmentNO_PROXYlocalhost,127.0.0.1,192.168.0.0/16# 3. 重启 Docker 服务sudosystemctl daemon-reloadsudosystemctl restartdocker代码片段python.jsom{HEADER:{prefix:header,body:[#!/usr/bin/env python3,# -*- encoding: utf-8 -*-,,File : $TM_FILENAME,Time : $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND,Author : Marin Bao,Version : 1.0,Contact : baomx20mails.jlu.edu.cn,ascription : License: Jilin university,brief :,,$1],},function:{prefix:function,body:[\\\,brief:,,Arguments:,,Returns:,,\\\,],},carla:{prefix:carla,body:[import glob,import os,import sys,,try:, sys.path.append(glob.glob(../carla/dist/carla-*%d.%d-%s.egg % (, sys.version_info.major,, sys.version_info.minor,, win-amd64 if os.name nt else linux-x86_64))[0]),except IndexError:, pass,,import carla,\n,],},logging:{prefix:logging,body:[import logging,,logging.basicConfig(format%(asctime)s - %(name)s - %(funcName)s - %(lineno)s - %(levelname)s - %(message)s,levellogging.INFO),logger logging.getLogger(__name__),],},ANSI Logging:{prefix:color_log,body:[# ANSI 颜色码,RESET \\\033[0m\,RED \\\033[0;31m\,GREEN \\\033[0;32m\,YELLOW \\\033[0;33m\,BLUE \\\033[0;34m\,,def log_info(msg):, print(f\{BLUE}[INFO] {RESET}{msg}\),,def log_success(msg):, print(f\{GREEN}[SUCCESS] {RESET}{msg}\),,def log_warning(msg):, print(f\{YELLOW}[WARNING] {RESET}{msg}\),,def log_error(msg):, print(f\{RED}[ERROR] {RESET}{msg}\)],description:ANSI color codes and logging functions for Python}}Cpp.json{// Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the// same ids are connected.// Example:// Print to console: {// prefix: log,// body: [// console.log($1);,// $2// ],// description: Log output to console// }HEADER:{prefix:header,body:[/*, File : $TM_FILENAME, Time : $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND, Author : Marin Bao, Version : 1.0, Contact : baomx20mails.jlu.edu.cn, Ascription : License: SINOTRUK, brief : ,*/,$1],description:C file header with metadata},ANSI Logging:{prefix:color_log,body:[#include iostream,#include string,#include fmt/format.h,#include fmt/ranges.h,,// ANSI 颜色码,inline constexpr auto RESET \\\033[0m\;,inline constexpr auto RED \\\033[0;31m\;,inline constexpr auto GREEN \\\033[0;32m\;,inline constexpr auto YELLOW \\\033[0;33m\;,inline constexpr auto BLUE \\\033[0;34m\;,,template typename... Args,inline void log_info(fmt::format_stringArgs... fmt, Args... args) {, std::cout BLUE \[INFO] \ RESET, fmt::format(fmt, std::forwardArgs(args)...), \\n;,},,template typename... Args,inline void log_success(fmt::format_stringArgs... fmt, Args... args) {, std::cout GREEN \[SUCCESS] \ RESET, fmt::format(fmt, std::forwardArgs(args)...), \\n;,},,template typename... Args,inline void log_warning(fmt::format_stringArgs... fmt, Args... args) {, std::cout YELLOW \[WARNING] \ RESET, fmt::format(fmt, std::forwardArgs(args)...), \\n;,},,template typename... Args,inline void log_error(fmt::format_stringArgs... fmt, Args... args) {, std::cerr RED \[ERROR] \ RESET, fmt::format(fmt, std::forwardArgs(args)...), \\n;,},$1],description:ANSI color codes and logging functions},ANSI Logging_1:{prefix:color_log_1,body:[#define log_info(msg) std::cout \\\033[0;34m\ \[INFO] \ \\\033[0m\ msg std::endl,#define log_error(msg) std::cout \\\033[0;31m\ \[ERROR] \ \\\033[0m\ msg std::endl,#define log_warning(msg) std::cout \\\033[0;33m\ \[WARNING] \ \\\033[0m\ msg std::endl,#define log_success(msg) std::cout \\\033[0;32m\ \[SUCCESS] \ \\\033[0m\ msg std::endl,$1],description:ANSI color codes and logging functions}}