Docker 入门

  • 官方文档
    https://docs.docker.com/

    https://hub.docker.com/

1、设置Docker存储库

  • 设置后可以从存储库安装和更新Docker
1、安装所需的包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
2、设置稳定存储库
sudo yum-config-manager  --add-repo https://download.docker.com/linux/centos/docker-ce.repo

2、安装Docker CE

  • 安装最新版Docker
    sudo yum install docker-ce docker-ce-cli containerd.io

3、使用阿里云Docker镜像加速

  • 获取加速器地址


    阿里云加速器
  • 配置本机Docker镜像
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

4、运行HelloWorld

docker run hello-world

//本地没找到,到远程库获取
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:0e11c388b664df8a27a901dce21eb89f11d8292f7fca1b3e3c4321bf7897bffe
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

你可能感兴趣的:(Docker 入门)