搬家带着开发环境走vscode 连接 docker

使用docker compose

创建文件 py36cpp7.yaml

version: '3'
services:
  py36cpp7:
    image: "registry.cn-hangzhou.aliyuncs.com/mkmk/centos:py36cpp7gdb"
    ports:
        - "30000:30000"
        - "30001:30001"
        - "30002:30002"
        - "30003:30003"
        - "30004:30004"
        - "30005:30005"
        - "30006:30006"
        - "30007:30007"
        - "30008:30008"
        - "30009:30009"
        - "30010:30010"
        - "30011:30011"
        - "30012:30012"
    restart: always
    entrypoint: "init"

dockercompose 启用服务

测试服务 前台运行

docker-compose  -f C:\Users\73444\Desktop\dockercompose\py36cpp7.yaml up

后台运行

docker-compose  -f C:\Users\73444\Desktop\dockercompose\py36cpp7.yaml up  -d

超级好用谁用谁知道

镜像地址 包含的工具
registry.cn-hangzhou.aliyuncs.com/mkmk/centos:py36cpp
  1. home目录中配置了gdb调试文件
  2. python36
  3. python27
  4. gcc73
  5. gcc48
  6. g++
  7. git
  8. vscode c lint
  9. vscode python lint

    升级一下 gcc 原来自带的是 4.8

    /usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
    #error This file requires compiler and library support for the \

    所以决定升级一下 gcc 到 7

    yum install centos-release-scl-rh centos-release-scl -y
    yum  update
    
    #选择自己喜欢(需要)的版本
    yum install devtoolset-{
        
        x}-gcc devtoolset-{
        
        x}-gcc-c++   
    source /opt/rh/devtoolset-{
        
        x}/enable
    
    yum install devtoolset-7-gcc devtoolset-7-gcc-c++   -y
    # 激活一次
    #source /opt/rh/devtoolset-7/enable
    #source /opt/rh/devtoolset-7-gcc-c++/enable
    
    # 永久激活
    mv  /usr/bin/gcc  /usr/bin/gcc4
    mv  /usr/bin/g++  /usr/bin/g++4
    ln -s /opt/rh/devtoolset-7/root/bin/gcc /usr/bin/gcc 
    ln -s /opt/rh/devtoolset-7/root/bin/g++ /usr/bin/g++
    
    更新之后就不会继续 报错提示啦
    

    打包个vscode开发镜像到云端

    先拉 centos 镜像

     docker pull registry.cn-hangzhou.aliyuncs.com/mkmk/centos:python366
    

    这个docker 配置
    ssh 密码
    lmk19980312
    python366

    这个不是完整的镜像, 完整的镜像是下边的 centos:py36cpp7v1

    配置好 c++ 和 python的开发容器

    dokcer pull 以后,在 vscode 中安装 remote container 以及 docker 插件即可,在容器内个搞开发,尽量就是采用 host 主机网络吧,这样开发,所有的代码构建都在容器之中,但是网页服务却可以映射到宿主机直接查看效果

    在 vscode中可以设置 proxy

    记得在宿主机中同意lan 中主机访问

    这个容器里边已经默认配置好了 python c++ 的代码格式化工具

    也解决了一部分 python2 和python3 在 yum中的冲突,镜像源 也换到了国内, 使用的时候 记得把代理改成自己局域网中的代理即可

    centos 容器后台运行的时候 尽量使用 init

    docker pull  registry.cn-hangzhou.aliyuncs.com/mkmk/centos:py36cpp  
    
    // 新增版本 更新了 vscode gdb 调试的配置
    docker pull   registry.cn-hangzhou.aliyuncs.com/mkmk/centos:py36cpp7gdb  
    
    //新增版本 更新了 gcc 7 g++ 7
    docker pull   registry.cn-hangzhou.aliyuncs.com/mkmk/centos:py36cpp7v1  
    
    //新更新了一个 v2 版本,增加了语法智能提示的功能
    docker pull  registry.cn-hangzhou.aliyuncs.com/mkmk/centos:py36cppv2
    
     docker run -d  --restart=always  --privileged=true  --name py36cpp7  registry.cn-hangzhou.aliyuncs.com/mkmk/centos:py36cpp7gdb    init
    
    网络映射配置
    --net host  即可
    

    尽量在 home 中做开发,这是个空目录

    先换常用的国内镜像源换上

    省略

    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
    
    

    vscode 常用配置

    {
        
        
        "files.eol": "\n",
        "remote.extensionKind": {
        
        
            "ms-azuretools.vscode-docker": "workspace"
        },
        "editor.tabSize": 2,
        "editor.formatOnSave": true,
        "http.proxy": "http://192.168.1.8:7890",
        "files.autoSave": "afterDelay",
        "[cpp]": {
        
        
            "editor.defaultFormatter": "ms-vscode.cpptools",
            "editor.quickSuggestions": true,
        },
        "[c]": {
        
        
            "editor.defaultFormatter": "ms-vscode.cpptools",
            "editor.quickSuggestions": true,
        },
        "C_Cpp.clang_format_sortIncludes": true,
        "C_Cpp.intelliSenseEngineFallback": "Enabled",
      
      "html.suggest.html5": true,
      "files.autoSave": "afterDelay",
      "go.useLanguageServer": true,
      "open-in-browser.default": "chrome",
      "view-in-browser.customBrowser": "chrome",
      "typescript.updateImportsOnFileMove.enabled": "always",
      "window.zoomLevel": 0,
      "editor.fontSize": 14,
      "workbench.editor.enablePreview": true, //预览模式关闭
      "editor.formatOnSave": true, // #每次保存的时候自动格式化
      // 自动修复
      "editor.codeActionsOnSave": {
        
        
        "source.fixAll.eslint": true,
      },
      "eslint.enable": true, //是否开启vscode的eslint
      // 配置 ESLint 检查的文件类型
      "eslint.validate": [
        "javascript",
        "vue",
        "html"
      ],
    }
    

    配置git

    yum install git 
    

    配置 c c++

    centos 自带 gcc485 安装 c++和 python3 即可

    yum install gcc-c++
    

    配置 go

    先不配了

    在这里插入代码片
    

    配置 npm

    先不配了

    在这里插入代码片
    

    猜你喜欢

    转载自blog.csdn.net/qq_43373608/article/details/107676242