1. 安装docker环境
1.1 安装docker 容器
sudo apt install docker.io
sudo systemctl status docke # 获取docker状态
sudo systemctl start docker # 启动docker
sudo systemctl stop docker # 停止docker
1.2 将添加docker用户组(重启生效)
sudo groupadd docker
sudo gpasswd -a $USER docker
2. 安装ubuntu18.04景象
2.1 拉取docker镜像
docker pull ubuntu:18.04
2.2 启动docker镜像
docker run -it ubuntu:18.04 /bin/bash
2.2 更新
apt update
2.3 添加用户以及sudo
apt install sudo
echo "%sudo ALL=(ALL:ALL) ALL" >> /etc/sudoers
echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
adduser q
echo "q ALL=(ALL:ALL) ALL" >> /etc/sudoers
3. 保存环境
3.1查询容器信息
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9a39a23ed652 ubuntu:18.04 "/bin/bash" 11 minutes ago Up 11 minutes kind_khayyam
7cfe7f1ca30b ubuntu:18.04 "/bin/bash" 25 minutes ago Exited (1) 11 minutes ago great_mendel
3.2 提交docker容器修改(容器不能关闭)
docker commit 9a39a23ed652 openharmony-ubuntu18.04.v00:20230709
3.3 保存镜像
docker save -o openharmony-ubuntu18.04.tar.gz openharmony-ubuntu18.04.v00:20230709
4. 运行docker指令
docker run -it -v $logcal_path:$remote_patch -u q -e PYTHONIOENCODING=utf-8 openharmony-ubuntu18.04.v00:20230709 /bin/bash