Docker Desktop for Windows:https://docs.docker.com/desktop/setup/install/windows-install/
设置镜像源:Settings → Docker Engine:
"registry-mirrors": [ "https://mirrors.ustc.edu.cn", "https://docker.unsee.tech", "https://docker.1panel.live", "https://mirror.azure.cn", "https://dockerpull.org" ],
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo # 基础仓库 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo # 额外仓库
yum clean all
yum makecache
iptables -F
getenforce
setenforce 0
vi /etc/selinux/config
reboot
systemctl disable firewalld
systemctl stop firewalld
cat < /etc/sysctl.d/docker.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.conf.default.rp_filter = 0 net.ipv4.conf.all.rp_filter = 0 net.ipv4.ip_forward = 1 EOF
modprobe br_netfilter # 加载br_netfilter模块 sysctl -p /etc/sysctl.d/docker.conf # 重新加载内核
yum list docker-ce --showduplicates | sort -r
yum install docker-ce-20.10.9 -y
yum remove docker-ce-20.10.9 -y
mkdir -p /etc/docker vi /etc/docker/daemon.json写入如下内容: {"registry-mirrors":["https://docker.mirrors.ustc.edu.cn/"]} systemctl daemon-reload # 开机启动docker
systemctl enable docker
systemctl restart docker
docker version
docker info
docker info | grep Root
使用docker来切换不同的发行版,内核使用的都是宿主机的内核。 # 获取ubuntu镜像 docker pull ubuntu # 运行容器且进入容器内,-i交互式命令操作,-t开启一个终端 # bash进入容器后,执行的命令 docker run -it ubuntu bash # --rm容器退出时删除该容器 docker run -it --rm ubuntu bash
cat /etc/lsb-release
exit
docker exec -it 容器id bash
docker pull busyboxbusybox是一个集成了数百个Linux命令的精简工具箱,只有几兆大小,被誉为Linux系统的瑞击军刀。
搜索镜像:docker search nginx
docker rmi busybox
docker run -it --name=busybox2 busybox
docker run -d -p 80:80 nginx
上述命令中,-t参数是分配一个伪终端,-i参数从终端STDIN 打开,同时使用-it参数可以进入交互模式。
在交互模式下,可以通过所创建的终端来输入命令,例如:ps aux,容器1号进程为sh命令,在容器内部并不能看到主机上的进程信息,因为容器内部和主机是完全隔离的。同时由于sh是1号进程,意味着如果通过exit退出sh,那么容器也会退出。
docker rm busybox2 # 要删除正在运行的容器,须加-f(--force)参数 docker rm -f busybox
本文作者:a
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!