首页 > 系统相关 >Docker - 在Rockly Linux 9.4 上安装Docker-CE

Docker - 在Rockly Linux 9.4 上安装Docker-CE

时间:2024-09-05 22:46:40浏览次数:10  
标签:Rockly node200 CE 64 ce Docker root docker


安装Docker-CE

修改repo源

修改为国内阿里源以提高安装速度

sed -e 's|^mirrorlist=|#mirrorlist=|g' \
    -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
    -i.bak \
    /etc/yum.repos.d/rocky*.repo

设置存储库

dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

安装

安装docker-ce时会同步安装containerd.io、docker-ce-cli、docker-buildx-plugin、docker-ce-rootless-extras和docker-compose-plugin。

dnf install -y docker-ce

此命令还会创建一个 docker组,但默认情况下不会向该组添加任何用户。

允许非root用户运行

Docker 守护程序绑定到 Unix 套接字,而不是 TCP 端口。
默认情况下,用户 root拥有 Unix 套接字,Docker守护程序始终以root用户身份运行,其他用户只能使用sudo访问。
如果不想docker在命令前加上sudo,可以创建一个名为docker的Unix组并向其中添加普通用户。

usermod -aG docker anliven
newgrp docker

设置自启动并启动

systemctl --now enable docker

验证安装

下载运行hello-world映像,容器运行时会打印一条确认消息并退出。

docker run hello-world

安装过程示例

[root@node200 ~]# uname -a
Linux node200 5.14.0-427.33.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 28 17:34:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
[root@node200 ~]# 
[root@node200 ~]# cat /etc/system-release
Rocky Linux release 9.4 (Blue Onyx)
[root@node200 ~]# 
[root@node200 ~]# dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
[root@node200 ~]# 
[root@node200 ~]# dnf install -y docker-ce
Rocky Linux 9 - BaseOS                                                                                       1.8 MB/s | 2.3 MB     00:01    
Rocky Linux 9 - AppStream                                                                                    4.4 MB/s | 8.0 MB     00:01    
Rocky Linux 9 - Extras                                                                                        20 kB/s |  15 kB     00:00    
Dependencies resolved.
=============================================================================================================================================
 Package                                    Architecture            Version                          Repository                         Size
=============================================================================================================================================
Installing:
 docker-ce                                  x86_64                  3:27.2.0-1.el9                   docker-ce-stable                   27 M
Installing dependencies:
 containerd.io                              x86_64                  1.7.21-3.1.el9                   docker-ce-stable                   43 M
 docker-ce-cli                              x86_64                  1:27.2.0-1.el9                   docker-ce-stable                  7.9 M
Installing weak dependencies:
 docker-buildx-plugin                       x86_64                  0.16.2-1.el9                     docker-ce-stable                   14 M
 docker-ce-rootless-extras                  x86_64                  27.2.0-1.el9                     docker-ce-stable                  4.0 M
 docker-compose-plugin                      x86_64                  2.29.2-1.el9                     docker-ce-stable                   13 M

Transaction Summary
=============================================================================================================================================
Install  6 Packages
......
......
......
Installed:
  containerd.io-1.7.21-3.1.el9.x86_64      docker-buildx-plugin-0.16.2-1.el9.x86_64           docker-ce-3:27.2.0-1.el9.x86_64               
  docker-ce-cli-1:27.2.0-1.el9.x86_64      docker-ce-rootless-extras-27.2.0-1.el9.x86_64      docker-compose-plugin-2.29.2-1.el9.x86_64     

Complete!
[root@node200 ~]#
[root@node200 ~]# usermod -aG docker anliven
[root@node200 ~]# newgrp docker
[root@node200 ~]#
[root@node200 ~]# systemctl --now enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@node200 ~]#
[root@node200 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete 
Digest: sha256:53cc4d415d839c98be39331c948609b659ed725170ad2ca8eb36951288f81b75
Status: Downloaded newer image for hello-world:latest

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

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

[root@node200 ~]#   
[root@node200 ~]# docker version
Client: Docker Engine - Community
 Version:           27.2.0
 API version:       1.47
 Go version:        go1.21.13
 Git commit:        3ab4256
 Built:             Tue Aug 27 14:17:06 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.2.0
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.21.13
  Git commit:       3ab5c7d
  Built:            Tue Aug 27 14:15:14 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.21
  GitCommit:        472731909fa34bd7bc9c087e4c27943f9835f111
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[root@node200 ~]#
[root@node200 ~]# docker info
Client: Docker Engine - Community
 Version:    27.2.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.16.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.29.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 1
 Server Version: 27.2.0
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 472731909fa34bd7bc9c087e4c27943f9835f111
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.14.0-427.33.1.el9_4.x86_64
 Operating System: Rocky Linux 9.4 (Blue Onyx)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.506GiB
 Name: node200
 ID: 0ba20da2-13b0-4424-a09e-5fba22a975c3
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
[root@node200 ~]#
[root@node200 ~]# docker compose version
Docker Compose version v2.29.2
[root@node200 ~]#   
[root@node200 ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   latest    d2c94e258dcb   16 months ago   13.3kB
[root@node200 ~]# 
[root@node200 ~]# docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED              STATUS                          PORTS     NAMES
8c9ba6bc04b1   hello-world   "/hello"   About a minute ago   Exited (0) About a minute ago             unruffled_driscoll
[root@node200 ~]# 

配置daemon.json

  • daemon.json是Docker守护进程配置文件
  • 修改 Docker 文件系统为 ovelay2 驱动
  • 配置 Docker 下载加速器地址(中国科学技术大学不需要进行认证)
cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn","https://mirror.iscas.ac.cn"],
  "insecure-registries":["docker.rockylinux.cn"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
     "max-size": "100m",
     "max-file": "10"
  },
  "storage-driver": "overlay2",
  "live-restore": true,
  "default-shm-size": "128M",
  "max-concurrent-downloads": 10,
  "max-concurrent-uploads": 10,
  "debug": false
}
EOF
systemctl daemon-reload

参考信息


标签:Rockly,node200,CE,64,ce,Docker,root,docker
From: https://www.cnblogs.com/anliven/p/18399355

相关文章

  • centos yum源配置
    yum源配置1.删除centos自带的yum源[root@cloud~]#rm-rf/etc/yum.repos.d/*2.创建挂载点并挂载镜像[root@cloud~]#mkdir/opt/centos[root@cloud~]#mount/dev/cdrom/opt/centos/mount:/dev/sr0写保护,将以只读方式挂载3.创建本地yum源[root@cloud~]#vi/e......
  • CodeForces 2009G Yunli's Subarray Queries 题解
    云璃!高质量Div.4,吊打某些Div.2Only/Edu/Div.3。本题是下面四道题目的有机结合,优雅且经典。LuoguP4168[Violet]蒲公英|LuoguP1997faebdc的烦恼|LuoguP3203[HNOI2010]弹飞绵羊|LuoguP3246[HNOI2016]序列建议先完成这四题。(必须指出:用蒲公英的分块方......
  • docker部署mysql8主从
     一、拉取mysql镜像dockerpullmysql 二、创建容器#主库dockerrun-itd-p3306:3306-eMYSQL_ROOT_PASSWORD=123456--namemysql-mastermysql#从库dockerrun-itd-p3307:3306-eMYSQL_ROOT_PASSWORD=123456--namemysql-slavemysql 三、配置主库[m......
  • BEVFormer复现(使用docker搭建训练环境)
    文章目录一、使用docker创建环境1.1创建容器1.2在容器中安装常用的包1.3安装miniconda1.4安装Pytorch二、环境配置2.1下载源码2.2安装mmcv-full2.3安装mmdet和mmseg2.4从源码安装mmdet3d2.5安装Detectron2和Timm2.6下载预训练模型三、数据准备3.1下载数据集......
  • 浙大数据结构:01-复杂度2 Maximum Subsequence Sum
    数据结构MOOCPTA习题01-复杂度2MaximumSubsequenceSum#include<iostream>usingnamespacestd;constintM=100005;inta[M];intmain(){ intk; cin>>k; intf=1; for(inti=0;i<k;i++) { cin>>a[i]; if(a[i]>=0)//如......
  • Docker常用命令
    Docker常用命令1.docker部署Mysql命令解读dockerrun-d\--namemysql\-p3306:3306\-eTZ=Asia/Shanghai\-eMYSQL_ROOT_PASSWORD=123\mysqldockerrun;创建并且运行一个容器,-d让容器在后台运行–namemysql意思是给容器取名字,唯一的-p3306:3......
  • 【Azure Policy】分享Policy实现对Azure Activity Log导出到Log A workspace中
    问题描述使用AzurePolicy服务,对公司内部全部的订阅下的ActivityLog,都需要配置导出到LogAWorkspace中。以下Policy规则可以实现此目的。 Policy内容说明在PolicyRule部分中,选择资源的类型为 "Microsoft.Resources/subscriptions",效果使用 DeployIfNotExists(如果不存在,则......
  • 深入解析 Docker exec 命令
      目录Dockerexec命令详解常用选项示例注意 Docker容器允许你在隔离的环境中运行应用程序,这样可以确保应用运行所需的环境是一致的,无论是在开发、测试还是生产环境中。当需要在Docker容器中执行命令时,通常会用到dockerexec命令。下面是对dockerexec命令......
  • Codeforces Round 968 (Div. 2)
    Preface今天课比较少,就抽点时间补一下之前欠的CF这场总体来说题还算简单,E1之前的题基本都是一眼,不过E2没往转化到区间不交的情况想,F更是完全没想到colorcoding,只能说太菜太菜A.TurtleandGoodStrings不难发现只要比较开头和结尾的字符是否相同即可#include<cstdio......
  • 【Azure Policy】分享Policy实现对Azure Activity Log导出到Log A workspace中
    问题描述使用AzurePolicy服务,对公司内部全部的订阅下的ActivityLog,都需要配置导出到LogAWorkspace中。以下Policy规则可以实现此目的。 Policy内容说明在PolicyRule部分中,选择资源的类型为 "Microsoft.Resources/subscriptions",效果使用 DeployIfNotExists(如果不......