IPQ5322 Docker开发环境搭建
制作docker 镜像
使用下面的命令制作qsdk12_ubuntu2004:v0.1 docker镜像:
docker build -t qsdk12_ubuntu2004:v0.1 .
其中Dockerfile文件如下:
# 使用 Ubuntu 20.04 官方镜像
FROM ubuntu:20.04
# 设置非交互式环境(避免安装提示)
ENV DEBIAN_FRONTEND=noninteractive
# 替换清华镜像源
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list && \
sed -i 's@//.*security.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list
# 安装基础工具和开发依赖
RUN apt-get update && \
apt-get install -y sudo net-tools iputils-ping tftpd-hpa nfs-kernel-server samba git wget vim && \
apt-get install -y gcc g++ binutils patch bzip2 flex make gettext pkg-config unzip zlib1g-dev rsync libc6-dev subversion libncurses5-dev gawk sharutils curl libxml-parser-perl ocaml-nox ocaml ocaml-findlib python-yaml libssl-dev libfdt-dev device-tree-compiler u-boot-tools && \
# 安装特定版本的 make 4.1
wget http://launchpadlibrarian.net/366014597/make_4.1-9.1ubuntu1_amd64.deb && \
dpkg -i make_4.1-9.1ubuntu1_amd64.deb && \
rm make_4.1-9.1ubuntu1_amd64.deb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 安装 repo 工具
RUN cd /usr/bin/ && \
wget https://storage.googleapis.com/git-repo-downloads/repo && \
chmod a+x ./repo
# 设置 Python 版本(默认使用 Python 2.7 和 Python 3.8)
RUN update-alternatives --install /usr/bin/python2 python2 /usr/bin/python2.7 2 && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 && \
# 设置系统默认的 Python 为 Python 2
update-alternatives --set python2 /usr/bin/python2.7 && \
update-alternatives --set python3 /usr/bin/python3.8
# 安装 32 位依赖库
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y libc6-i386 libgl1-mesa-dri:i386 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 配置 Git 账号(建议运行容器后根据需求修改)
RUN git config --global user.name "FlyRobot" && \
git config --global user.email "xyan_m@163.com"
# 设置时区为 Asia/Shanghai
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
# 创建用户并设置密码
RUN useradd -m -s /bin/bash -U book && \
echo "book:123456" | chpasswd && \
usermod -aG sudo book
# 创建目录并设置权限
RUN bash -c 'mkdir -p /home/book/{nfs_rootfs,tftpboot,works}' && \
chown -R book:book /home/book
# 配置 TFTP 服务器
RUN echo 'TFTP_USERNAME="tftp"\nTFTP_DIRECTORY="/home/book/tftpboot"\nTFTP_ADDRESS="0.0.0.0:69"\nTFTP_OPTIONS="-l -c -s"' > /etc/default/tftpd-hpa
# 配置 NFS 服务器
RUN echo "/home/book/nfs_rootfs *(rw,sync,no_subtree_check,no_root_squash)" >> /etc/exports
# 配置 Samba 服务器
RUN echo "[book-share]\ncomment = Book's Share\npath = /home/book\nvalid users = book\nread only = no\nbrowsable = yes" >> /etc/samba/smb.conf && \
(echo "123456"; echo "123456") | smbpasswd -a -s -L book
# 切换默认用户
USER book
WORKDIR /home/book
创建数据卷
64位
docker volume create qsdk12_5322_64_vol setenv qs "tftpboot nand-ipq5322-apps.img && imgaddr=$fileaddr && source $imgaddr:script && re"
32位
docker volume create qsdk12_5322_32_vol
启动docker容器
64位:
docker run -h docker \ --name qsdk12_64_container \ -it --privileged=true \ --mount type=volume,source=qsdk12_5322_64_vol,target=/home/book/works \ -v /home/book/tftpboot:/home/book/tftpboot \ --mount type=bind,source=/mnt,target=/mnt/windows \ -w /home/book \ --user book \ qsdk12_ubuntu2004:v0.1 bash
32位
docker run -h docker \ --name qsdk12_32_container \ -it --privileged=true \ --mount type=volume,source=qsdk12_5322_32_vol,target=/home/book/works \ -v /home/book/tftpboot:/home/book/tftpboot \ --mount type=bind,source=/mnt,target=/mnt/windows \ -w /home/book \ --user book \ qsdk12_ubuntu2004:v0.1 bash