搭建Docker开发环境_Linux

环境搭建

### 文章目录

  • [环境搭建](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [@[toc]](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [Docker](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [Docker运行权限](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [Docker加速](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [Docker容器创建](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [Python版本切换](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [版本工具](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [Repo](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [Git](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [开发](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [SDK代码拉取](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [在线](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [离线(推荐)](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [Debian](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [安装软件包](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [编译](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [打包](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [问题](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)
  • [技巧](#文章目录 环境搭建 @[toc] Docker Docker运行权限 Docker加速 Docker容器创建 Python版本切换 版本工具 Repo Git 开发 SDK代码拉取 在线 离线(推荐) Debian 安装软件包 编译 打包 问题 技巧)

Docker

shell 复制代码
sudo apt  install docker.io

Docker运行权限

shell 复制代码
#添加docker group
sudo groupadd docker
​
# 将当前用户添加到docker组
sudo gpasswd -a ${USER} docker
​
# 重启docker服务:
sudo service docker restart
​
# 查看用户组及成员:
cat /etc/group | grep docker

Docker加速

shell 复制代码
# 编辑 Docker 配置文件
$ sudo vim /etc/docker/daemon.json
​
# 加入以下配置项
{
    "registry-mirrors": [
        "https://dockerproxy.com",
        "https://hub-mirror.c.163.com",
        "https://mirror.baidubce.com",
        "https://ccr.ccs.tencentyun.com"
    ]
}
​
# 重启docker
$ sudo service docker restart

Docker容器创建

shell 复制代码
# 推荐:Ubuntu 18.04 版本  
# 拉取Ubuntu镜像
docker pull ubuntu:18.04

# 进入关联源码目录挂载使用绝对路径,启动Docker
cd ~
docker run -it -v ${PWD}:${PWD} --privileged --name Ubuntu18_Lubancat2 ubuntu:18.04

# 环境依赖
apt-get update

# Docker 补充
apt install -y bc time rsync curl vim sudo

# 安装 SDK 构建所需要的软件包
apt install -y git ssh make gcc libssl-dev liblz4-tool u-boot-tools curl \
expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \
qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib \
unzip device-tree-compiler python-pip libncurses5-dev python3-pyelftools \
dpkg-dev

# 添加用户
adduser gaoyang3513

# 为用户username添加sudo权限
sudo usermod -a -G sudo gaoyang3513

# sudo 免密,在sudoer.d目录新建docker-nopasswd
#    添加内容:gaoyang3513 ALL=(ALL) NOPASSWD: ALL
sudo visudo /etc/sudoers.d/docker-nopassswd

# 切换用户
su gaoyang3513

Python版本切换

shell 复制代码
# 添加,优先python3
update-alternatives --install /usr/bin/python python /usr/bin/python2 100
update-alternatives --install /usr/bin/python python /usr/bin/python3 150
​
# 切换
update-alternatives --config python

版本工具

Repo

shell 复制代码
# 环境配置
mkdir -p ~/.local/bin/
export PATH=~/.local/bin/:$PATH

# 下载
curl https://storage.googleapis.com/git-repo-downloads/repo > .local/bin/repo

# 权限
chmod a+x .local/bin/repo

# 生效
source .profile

Git

shell 复制代码
git config --global user.name "gaoyang3513"
git config --global user.email "gaoyang3513@163.com"

git config --global core.editor vim

开发

SDK代码拉取

在线
shell 复制代码
#github地址
repo --trace init --depth=1 --repo-url https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -u https://github.com/LubanCat/manifests.git -b linux -m rk356x_linux_release.xml 

# 同步源码
repo --trace sync -c -j4
离线(推荐)
shell 复制代码
# 离线SDK,解压
cd SDK_RK3568_Linux_New 
7z x ../../01-Resource/01-鲁班猫/8-SDK源码压缩包/LubanCat_rk356x_Linux_SDK_20230711.7z

repo init --depth=1 -u https://github.com/LubanCat/manifests.git -b linux -m rk356x_linux_release.xml

# 检出.repo 目录下的 git 仓库并同步
repo sync -l -j10
# 不推荐同步
# repo sync -c -j10

Debian

安装软件包

shell 复制代码
sudo apt install binfmt-support qemu-user-static

# 安装 debian 根文件系统构建依赖的软件包,无视过程报错
sudo dpkg -i debian/ubuntu-build-service/packages/*
sudo apt-get install -f

编译

shell 复制代码
# 选择目标
#     10. BoardConfig-LubanCat-RK3568-debian-xfce.mk
./build.sh lunch

打包

shell 复制代码
# 一键编译 u-Boot, kernel, Rootfs, Recovery, 并打包为 update.img 镜像
./build.sh

问题

  • 错误1../build.sh: line 717: /usr/bin/time: No such file or directory
shell 复制代码
atp instal -y time
  • 错误2. 2023-09-08T01:18:53 You must install 'rsync' on your build machine

    shell 复制代码
    apt install -y rsync
  • 错误3. fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle

    diff 复制代码
    # vi ~/bin/repo
    ​
    - REPO_URL = 'https://gerrit.googlesource.com/git-repo'
    + REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'

    或repo init时参数--repo-url指定,如:--repo-url https://mirrors.tuna.tsinghua.edu.cn/git/git-repo

  • 错误.Failed to run livebuild, please check your network connection.

    shell 复制代码
    if [ -f binary-tar.tar.gz ]; then \
            tar -jcf linaro-buster-alip-`date +%Y%m%d`-1.config.tar.bz2 auto/ config/ configure; \
            sudo mv binary.contents linaro-buster-alip-`date +%Y%m%d`-1.contents; \
            sudo mv chroot.packages.live linaro-buster-alip-`date +%Y%m%d`-1.packages; \
            sudo mv binary-tar.tar.gz linaro-buster-alip-`date +%Y%m%d`-1.tar.gz; \
            md5sum linaro-buster-alip-`date +%Y%m%d`-1.build-log.txt linaro-buster-alip-`date +%Y%m%d`-1.config.tar.bz2 linaro-buster-alip-`date +%Y%m%d`-1.contents linaro-buster-alip-`date +%Y%m%d`-1.packages linaro-buster-alip-`date +%Y%m%d`-1.tar.gz > linaro-buster-alip-`date +%Y%m%d`-1.md5sums.txt; \
            sha1sum linaro-buster-alip-`date +%Y%m%d`-1.build-log.txt linaro-buster-alip-`date +%Y%m%d`-1.config.tar.bz2 linaro-buster-alip-`date +%Y%m%d`-1.contents linaro-buster-alip-`date +%Y%m%d`-1.packages linaro-buster-alip-`date +%Y%m%d`-1.tar.gz > linaro-buster-alip-`date +%Y%m%d`-1.sha1sums.txt; \
    fi
     Failed to run livebuild, please check your network connection. 
    VERSION=none TARGET=xfce SOC=rk356x ./mk-buster-rootfs.sh

    直接原因为binary-tar.tar.gz文件未生成,根本原因为qemu中挂载/proc目录失败,解决方案:参考1.docker 中使用mount命令报错:mount: permission denied

技巧

shell 复制代码
# 新开
docker exec -it Ubuntu20_RK3568 /bin/bash
相关推荐
上天_去_做颗惺星 EVE_BLUE17 小时前
Docker高效使用指南:从基础到实战模板
开发语言·ubuntu·docker·容器·mac·虚拟环境
Yana.nice17 小时前
openssl将证书从p7b转换为crt格式
java·linux
AI逐月18 小时前
tmux 常用命令总结:从入门到稳定使用的一篇实战博客
linux·服务器·ssh·php
小白跃升坊18 小时前
基于1Panel的AI运维
linux·运维·人工智能·ai大模型·教学·ai agent
跃渊Yuey18 小时前
【Linux】线程同步与互斥
linux·笔记
舰长11518 小时前
linux 实现文件共享的实现方式比较
linux·服务器·网络
好好沉淀18 小时前
Docker开发笔记(详解)
运维·docker·容器
zmjjdank1ng19 小时前
Linux 输出重定向
linux·运维
路由侠内网穿透.19 小时前
本地部署智能家居集成解决方案 ESPHome 并实现外部访问( Linux 版本)
linux·运维·服务器·网络协议·智能家居
VekiSon19 小时前
Linux内核驱动——基础概念与开发环境搭建
linux·运维·服务器·c语言·arm开发