ubuntu 安装docker

ubuntu 安装docker,第1张

一、安装docker

1、安装docker:sudo apt-get install -y docker.io

2、启动docker服务:systemctl start docker

3、设置开机启动:systemctl enable docker

4、查看docker状态:systemctl status docker

5、停止docker服务:凳肆缓systemctl stop docker

6、查看docker版本枣模雹败:docker version

二、非root用户运行docker

1、添加docker用户组:sudo groupadd docker

执行以上命令会提示已存在,原因是在安装docker时已自动创建。

2、将指定用户添加到用户组(username为你的用户名):sudo gpasswd -a username docker

3、查看是否添加成功:cat /etc/group | grep ^docker

3、重启docker:sudo systemctl restart docker

5、更新用户组:newgrp docker

6、执行docker命令,比如:docker ps -a

运慧轿行 *** 作系统: 

docker01:/etc/apt$ cat /etc/issue

Ubuntu 20.10 \n \l

参考文档前高肆:docker官网文档

Install Docker Engine on Ubuntu | Docker Documentation

一、安装docker

安装依赖:

docker01:/etc/apt$ sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release

添加信任的念绝GPG key

@docker01:~$ curl -fsSL  https://download.docker.com/linux/ubuntu/gpg |sudo gpg  --dearmor  -o  /usr/share/keyrings/docker-archive-keyring.gpg

添加docker的镜像源

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

docker01:/etc/apt$ sudo apt-get update

安装docker

docker01:/etc/apt$ sudo apt-get install docker-ce docker-ce-cli containerd.io

添加docker服务开机自启动,并启动docker

docker01:/etc/apt$ sudo systemctl enable docker

查看docker 服务状态

docker01:/etc/apt$ sudo systemctl status docker

● docker.service - Docker Application Container Engine

    Loaded: loaded (/lib/systemd/system/docker.serviceenabledvendor preset: enabled)

    Active: active (running) since Wed 2021-09-08 22:24:13 CST4min 53s ago

TriggeredBy: ● docker.socket

      Docs: https://docs.docker.com

  Main PID: 9398 (dockerd)

      Tasks: 8

    Memory: 28.8M

    CGroup: /system.slice/docker.service

            └─9398 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Sep 08 22:24:13 docker01 dockerd[9398]: time="2021-09-08T22:24:13.197566481+08:00" level=warning msg="Your kernel does not support CPU realtime scheduler"

Sep 08 22:24:13 docker01 dockerd[9398]: time="2021-09-08T22:24:13.197643255+08:00" level=warning msg="Your kernel does not support cgroup blkio weight"

Sep 08 22:24:13 docker01 dockerd[9398]: time="2021-09-08T22:24:13.197658253+08:00" level=warning msg="Your kernel does not support cgroup blkio weight_device"

Sep 08 22:24:13 docker01 dockerd[9398]: time="2021-09-08T22:24:13.198185693+08:00" level=info msg="Loading containers: start."

Sep 08 22:24:13 docker01 dockerd[9398]: time="2021-09-08T22:24:13.436407447+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Dae>

Sep 08 22:24:13 docker01 dockerd[9398]: time="2021-09-08T22:24:13.531857430+08:00" level=info msg="Loading containers: done."

Sep 08 22:24:13 docker01 dockerd[9398]: time="2021-09-08T22:24:13.616001469+08:00" level=info msg="Docker daemon" commit=75249d8 graphdriver(s)=overlay2 version=20.10.8

Sep 08 22:24:13 docker01 dockerd[9398]: time="2021-09-08T22:24:13.616363666+08:00" level=info msg="Daemon has completed initialization"

Sep 08 22:24:13 docker01 systemd[1]: Started Docker Application Container Engine.

Sep 08 22:24:13 docker01 dockerd[9398]: time="2021-09-08T22:24:13.641779103+08:00" level=info msg="API listen on /run/docker.sock"


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12542000.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存