Docker学习笔记1

安装docker环境(参考地址:https://www.runoob.com/docker/centos-docker-install.html)

1.1、Uninstall old versions(卸载老版本)

  sudo yum remove docker \
             docker-client \
             docker-client-latest \
             docker-common \
             docker-latest \
             docker-latest-logrotate \
             docker-logrotate \
             docker-engin

1.2、Install using the repository(使用 Docker 仓库进行安装)

a、配置yum源

  sudo yum install -y yum-utils
  sudo yum-config-manager \
     --add-repo \
     https://download.docker.com/linux/centos/docker-ce.repo

b、使用阿里云yum源,解决国外网速慢的问题

  sudo yum install -y yum-utils

   sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

1.3、安装Docker

   sudo yum install -y docker-ce docker-ce-cli containerd.io

   #以下是在安装k8s的时候使用
   yum install -y docker-ce-20.10.7 docker-ce-cli-20.10.7  containerd.io-1.4.6

1.4、Start Docker.

  #启动方式1、
  sudo systemctl start docker

           #启动方式2、

           systemctl enable docker --now

1.5、配置加速

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

  

1.6、运行hello word

  sudo docker run hello-world

 

 

 



 

 

posted @ 2021-06-03 09:24  西风51668  阅读(34)  评论(0编辑  收藏  举报