You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 18.04如何安装Docker及解决启动服务时的systemd报错

Ubuntu 18.04 Docker安装及启动问题解答

一、系统内正确安装Docker的步骤

  • 更新本地软件包索引
    sudo apt update
  • 安装HTTPS传输相关依赖包
    sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  • 添加Docker官方GPG密钥
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • 接入Docker稳定版软件源
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  • 安装Docker引擎及相关组件
    sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io
  • 验证安装结果,执行后正常输出版本号即为安装成功
    docker --version

二、Docker服务正确启动操作

你执行systemctl start docker时收到的报错如下:

System has not been booted with systemd as init system (PID 1). Can't operate.
该报错说明当前运行的Ubuntu 18.04环境没有使用systemd作为1号初始化进程,常见于WSL环境、容器内运行Ubuntu、自定义init系统的场景,无法使用systemctl指令管理服务,对应启动方式如下:

非systemd环境(匹配当前报错场景)

  • 前台运行Docker守护进程
    sudo dockerd
  • 如需后台运行,执行
    sudo dockerd &
  • 启动前可先清理残留进程避免冲突
    sudo killall dockerd
  • 执行以下指令验证启动结果,正常输出Docker运行信息即为启动成功
    sudo docker info

标准systemd环境

如果是正常安装运行在物理机/虚拟机、使用systemd作为init系统的Ubuntu 18.04,使用以下指令操作:

  • 启动Docker服务
    sudo systemctl start docker
  • 设置开机自启
    sudo systemctl enable docker
  • 查看服务运行状态
    sudo systemctl status docker

内容的提问来源于stack exchange,提问作者janani durairajan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.21 10:09:00