参考

https://docs.docker.com/engine/install/

https://docs.docker.com/desktop/install/fedora/

https://docs.docker.com/engine/install/centos/

1. 介绍

容器。

需要用root权限下载直接劝退。

2. 安装

  1. sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  1. Error:
  2. Problem 1: problem with installed package podman-3.3.1-9.module_el8.5.0+988+b1f0b741.x86_64
  1. Error:
  2. Problem 1: problem with installed package containers-common-2:1-2.module_el8.5.0+890+6b136101.noarch
  • 尝试运行
  1. sudo systemctl start docker
  2. sudo docker run hello-world
  • 重启docker
  1. sudo systemctl restart docker

3. 为普通用户添加docker权限

  • 查看是否有docker分组,没有结果表示没有docker分组,需要手动添加。
  1. sudo cat /etc/group | grep docker
  • 手动添加docker分组,已有docker分组时忽略此步
  1. sudo groupadd docker
  • 将普通用户添加到docker分组
  1. sudo gpasswd -a shwzhao docker
  2. ## Adding user shwzhao to group docker
  • 检查
  1. sudo cat /etc/group | grep docker
  2. ## docker:x:967:hyma,shwzhao
  • 更新分组
  1. id
  2. ## uid=1001(shwzhao) gid=1001(shwzhao) groups=1001(shwzhao)
  3. newgrp docker
  4. id
  5. ## uid=1001(shwzhao) gid=967(docker) groups=967(docker),1001(shwzhao)
  • 普通用户运行docker
  1. docker run hello-world
  2. ##
  3. ## Hello from Docker!
  4. ## This message shows that your installation appears to be working correctly.
  5. ##
  6. ## To generate this message, Docker took the following steps:
  7. ## 1. The Docker client contacted the Docker daemon.
  8. ## 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
  9. ## (amd64)
  10. ## 3. The Docker daemon created a new container from that image which runs the
  11. ## executable that produces the output you are currently reading.
  12. ## 4. The Docker daemon streamed that output to the Docker client, which sent it
  13. ## to your terminal.
  14. ##
  15. ## To try something more ambitious, you can run an Ubuntu container with:
  16. ## $ docker run -it ubuntu bash
  17. ##
  18. ## Share images, automate workflows, and more with a free Docker ID:
  19. ## https://hub.docker.com/
  20. ##
  21. ## For more examples and ideas, visit:
  22. ## https://docs.docker.com/get-started/
  23. ##

4. 使用