Ubuntu 在线 安装 Docker

2023-12-14 19:48:08

Ubuntu 在线 安装 Docker

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

开启国内镜像加速

修改 /etc/docker/daemon.json 文件(若无自己创建),修改为如下形式

{
  "registry-mirrors": [
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn"
  ]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker info

开启docker 远程访问API

sudo vim /lib/systemd/system/docker.service
# 找到ExecStartExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H 
# 修改为
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
# 保存退出。
sudo systemctl daemon-reload
sudo systemctl restart docker
curl http://ip:2375/version

文章来源:https://blog.csdn.net/qq_24330181/article/details/134849130
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。