您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
centos7二进制安装docker及docker hello world项目运行
发布时间:2022-02-08 23:24:57编辑:雪饮阅读()
为什么选择二进制方式安装,因为centos7,docker并没有为它提供,虽然提供了rhel
但是它提供的rhel不支持我的x86_64的cpu架构。
安装的先决条件:
Prerequisites
Before attempting to install Docker from binaries, be sure your host machine meets the prerequisites:
A 64-bit installation
Version 3.10 or higher of the Linux kernel. The latest version of the kernel available for your platform is recommended.
iptables version 1.4 or higher
git version 1.7 or higher
A ps executable, usually provided by procps or a similar package.
XZ Utils 4.9 or higher
A properly mounted cgroupfs hierarchy; a single, all-encompassing cgroup mount point is not sufficient. See Github issues #2683, #3485, #4568).
该命令的执行结果满足了先决条件的64位和内核3.10
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
该命令的执行结果满足了git版本要求
[root@localhost ~]# git --version
git version 1.8.3.1
该命令的执行结果满足了iptables要求
[root@localhost ~]# iptables --version
iptables v1.4.21
该命令的执行结果满足了xz的版本要求
[root@localhost ~]# xz --version
xz (XZ Utils) 5.2.2
liblzma 5.2.2
安装并运行服务端
下载一个合适的二进制包:
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.6.tgz
解压
tar -zxvf docker-20.10.6.tgz
docker服务端启动
./dockerd
这里可能会报错包含如:
rror starting daemon: error while opening volume store metadata database: timeout
这样的错误。
解决方法:
ps axf | grep docker | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh
具体这里原理还不清楚
如果没有什么大问题,dockerd的执行结果应如是:
[root@localhost docker]# ./dockerd
INFO[2022-02-08T19:55:47.796437685+08:00] Starting up
WARN[2022-02-08T19:55:47.797429340+08:00] could not change group /var/run/docker.sock to docker: group docker not found
INFO[2022-02-08T19:55:47.798318908+08:00] libcontainerd: started new containerd process pid=60738
INFO[2022-02-08T19:55:47.798401448+08:00] parsed scheme: "unix" module=grpc
INFO[2022-02-08T19:55:47.798411676+08:00] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2022-02-08T19:55:47.798425620+08:00] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock <nil> 0 <nil>}] <nil> <nil>} module=grpc
INFO[2022-02-08T19:55:47.798432687+08:00] ClientConn switching balancer to "pick_first" module=grpc
INFO[2022-02-08T19:55:47.811611930+08:00] starting containerd revision=05f951a3781f4f2c1911b05e61c160e9c30eaa8e version=v1.4.4
INFO[2022-02-08T19:55:47.826616295+08:00] loading plugin "io.containerd.content.v1.content"... type=io.containerd.content.v1
INFO[2022-02-08T19:55:47.826704104+08:00] loading plugin "io.containerd.snapshotter.v1.aufs"... type=io.containerd.snapshotter.v1
INFO[2022-02-08T19:55:47.827758297+08:00] skip loading plugin "io.containerd.snapshotter.v1.aufs"... error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: FATAL: Module aufs not found.\\n\"): skip plugin" type=io.containerd.snapshotter.v1
INFO[2022-02-08T19:55:47.827780223+08:00] loading plugin "io.containerd.snapshotter.v1.btrfs"... type=io.containerd.snapshotter.v1
INFO[2022-02-08T19:55:47.827899801+08:00] skip loading plugin "io.containerd.snapshotter.v1.btrfs"... error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs (xfs) must be a btrfs filesystem to be used with the btrfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1
INFO[2022-02-08T19:55:47.827911894+08:00] loading plugin "io.containerd.snapshotter.v1.devmapper"... type=io.containerd.snapshotter.v1
WARN[2022-02-08T19:55:47.827926717+08:00] failed to load plugin io.containerd.snapshotter.v1.devmapper error="devmapper not configured"
INFO[2022-02-08T19:55:47.827932609+08:00] loading plugin "io.containerd.snapshotter.v1.native"... type=io.containerd.snapshotter.v1
INFO[2022-02-08T19:55:47.827946730+08:00] loading plugin "io.containerd.snapshotter.v1.overlayfs"... type=io.containerd.snapshotter.v1
INFO[2022-02-08T19:55:47.828001086+08:00] loading plugin "io.containerd.snapshotter.v1.zfs"... type=io.containerd.snapshotter.v1
INFO[2022-02-08T19:55:47.828098226+08:00] skip loading plugin "io.containerd.snapshotter.v1.zfs"... error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1
INFO[2022-02-08T19:55:47.828111382+08:00] loading plugin "io.containerd.metadata.v1.bolt"... type=io.containerd.metadata.v1
WARN[2022-02-08T19:55:47.828120797+08:00] could not use snapshotter devmapper in metadata plugin error="devmapper not configured"
INFO[2022-02-08T19:55:47.828126264+08:00] metadata content store policy set policy=shared
INFO[2022-02-08T19:55:47.828226243+08:00] loading plugin "io.containerd.differ.v1.walking"... type=io.containerd.differ.v1
INFO[2022-02-08T19:55:47.828238398+08:00] loading plugin "io.containerd.gc.v1.scheduler"... type=io.containerd.gc.v1
INFO[2022-02-08T19:55:47.828273260+08:00] loading plugin "io.containerd.service.v1.introspection-service"... type=io.containerd.service.v1
INFO[2022-02-08T19:55:47.828296778+08:00] loading plugin "io.containerd.service.v1.containers-service"... type=io.containerd.service.v1
INFO[2022-02-08T19:55:47.828305924+08:00] loading plugin "io.containerd.service.v1.content-service"... type=io.containerd.service.v1
INFO[2022-02-08T19:55:47.828312514+08:00] loading plugin "io.containerd.service.v1.diff-service"... type=io.containerd.service.v1
INFO[2022-02-08T19:55:47.828337157+08:00] loading plugin "io.containerd.service.v1.images-service"... type=io.containerd.service.v1
INFO[2022-02-08T19:55:47.828348851+08:00] loading plugin "io.containerd.service.v1.leases-service"... type=io.containerd.service.v1
INFO[2022-02-08T19:55:47.828357470+08:00] loading plugin "io.containerd.service.v1.namespaces-service"... type=io.containerd.service.v1
INFO[2022-02-08T19:55:47.828364648+08:00] loading plugin "io.containerd.service.v1.snapshots-service"... type=io.containerd.service.v1
INFO[2022-02-08T19:55:47.828371457+08:00] loading plugin "io.containerd.runtime.v1.linux"... type=io.containerd.runtime.v1
INFO[2022-02-08T19:55:47.828426159+08:00] loading plugin "io.containerd.runtime.v2.task"... type=io.containerd.runtime.v2
INFO[2022-02-08T19:55:47.828481851+08:00] loading plugin "io.containerd.monitor.v1.cgroups"... type=io.containerd.monitor.v1
INFO[2022-02-08T19:55:47.828727737+08:00] loading plugin "io.containerd.service.v1.tasks-service"... type=io.containerd.service.v1
INFO[2022-02-08T19:55:47.828745253+08:00] loading plugin "io.containerd.internal.v1.restart"... type=io.containerd.internal.v1
INFO[2022-02-08T19:55:47.828777606+08:00] loading plugin "io.containerd.grpc.v1.containers"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828786322+08:00] loading plugin "io.containerd.grpc.v1.content"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828794071+08:00] loading plugin "io.containerd.grpc.v1.diff"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828800587+08:00] loading plugin "io.containerd.grpc.v1.events"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828829219+08:00] loading plugin "io.containerd.grpc.v1.healthcheck"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828837742+08:00] loading plugin "io.containerd.grpc.v1.images"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828844017+08:00] loading plugin "io.containerd.grpc.v1.leases"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828849994+08:00] loading plugin "io.containerd.grpc.v1.namespaces"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828855971+08:00] loading plugin "io.containerd.internal.v1.opt"... type=io.containerd.internal.v1
INFO[2022-02-08T19:55:47.828877326+08:00] loading plugin "io.containerd.grpc.v1.snapshots"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828887061+08:00] loading plugin "io.containerd.grpc.v1.tasks"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828896459+08:00] loading plugin "io.containerd.grpc.v1.version"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.828902732+08:00] loading plugin "io.containerd.grpc.v1.introspection"... type=io.containerd.grpc.v1
INFO[2022-02-08T19:55:47.829066156+08:00] serving... address=/var/run/docker/containerd/containerd-debug.sock
INFO[2022-02-08T19:55:47.829105147+08:00] serving... address=/var/run/docker/containerd/containerd.sock.ttrpc
INFO[2022-02-08T19:55:47.829140083+08:00] serving... address=/var/run/docker/containerd/containerd.sock
INFO[2022-02-08T19:55:47.829152992+08:00] containerd successfully booted in 0.018588s
INFO[2022-02-08T19:55:47.833136314+08:00] parsed scheme: "unix" module=grpc
INFO[2022-02-08T19:55:47.833150959+08:00] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2022-02-08T19:55:47.833160381+08:00] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock <nil> 0 <nil>}] <nil> <nil>} module=grpc
INFO[2022-02-08T19:55:47.833167248+08:00] ClientConn switching balancer to "pick_first" module=grpc
INFO[2022-02-08T19:55:47.833688471+08:00] parsed scheme: "unix" module=grpc
INFO[2022-02-08T19:55:47.833702000+08:00] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2022-02-08T19:55:47.833712361+08:00] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock <nil> 0 <nil>}] <nil> <nil>} module=grpc
INFO[2022-02-08T19:55:47.833716987+08:00] ClientConn switching balancer to "pick_first" module=grpc
INFO[2022-02-08T19:55:47.843805913+08:00] [graphdriver] using prior storage driver: overlay2
INFO[2022-02-08T19:55:47.846212372+08:00] Loading containers: start.
INFO[2022-02-08T19:55:47.904611782+08:00] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address
INFO[2022-02-08T19:55:47.927111903+08:00] Loading containers: done.
INFO[2022-02-08T19:55:47.944827094+08:00] Docker daemon commit=8728dd2 graphdriver(s)=overlay2 version=20.10.6
INFO[2022-02-08T19:55:47.944886355+08:00] Daemon has completed initialization
INFO[2022-02-08T19:55:47.954525868+08:00] API listen on /var/run/docker.sock
然后可以再启动一个会话了执行一个docker的hello world的项目的运行,因为这里并没有后台运行,所以只能另开会话了。
[root@localhost ~]# cd docker
[root@localhost docker]# ./docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
Digest: sha256:507ecde44b8eb741278274653120c2bf793b174c06ff4eaa672b713b3263477b
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/
这样就ok了
关键字词:centos7,二进制,安装,docker,hello,world,项目,运行
上一篇:GatewayWorker-Linux系统快速开始(从一个精简的聊天demo开始)
下一篇:解決centos7二進制方式安裝docker啓動dockerd報錯中包含"executable file not found in $PATH"