安装docker
sudo apt install docker-ce docker-io docker-ce-cli containerd.io
或者
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
启动docker服务
sudo service docker start
检测docker
rui@DESKTOP-QVG2107:/mnt/d/docker$ sudo service docker status
* Docker is not running
拉基础镜像:
sudo docker pull ubuntu:20.04
查看镜像容器
# 查看镜像
sudo docker image ls
# 查看容器
sudo docker ps -a
# 删除镜像
sudo docker rmi ubuntu:20.04
# 删除容器
sudo docker rm -f <容器id/容器名字>
进入镜像:启动容器
# sudo docker run --hostname=rv1126 -v /mnt/e/0dockerdata/rk1126:/home/work -it --name rv1126 -p 50021:21 -p 50022:22 ubuntu:20.04 /bin/bash
sudo docker run --hostname=rv1126 -v /mnt/d/dockerdata/1126:/home/work -it --name rv1126 -p 50021:21 -p 50022:22 ubuntu:20.04 /bin/bash
新建终端进入容器
使用该命令时,容器已经启动了。
# 启动容器
sudo docker start 容器id
# sudo docker exec -it [容器名]/[容器ID] /bin/bash
sudo docker exec -it rv1126 /bin/bash
更改镜像源
sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
sed -i s@/security.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
apt clean
apt-get update -y
apt-get upgrade -y
安装工具链
apt-get install git gnupg flex bison gperf \
build-essential zip curl zlib1g-dev gcc-multilib \
g++-multilib libc6-dev-i386 lib32ncurses-dev \
x11proto-core-dev libx11-dev lib32z1-dev time \
ccache libgl1-mesa-dev libxml2-utils libssl-dev \
xsltproc unzip device-tree-compiler liblz4-tool \
libfile-which-perl sed make binutils gcc g++ \
bash patch gzip bzip2 perl tar cpio python \
unzip rsync file bc libmpc3 git texinfo expect \
pkg-config cmake tree texinfo m4 autoconf automake sshpass \
libncurses5-dev openssh-server -y
-
其中有设置时区的:
选择亚洲:6
选择上海:70 -
增加sudo用户