Docker安装

1. 环境校验

在 CentOS 7安装docker要求系统为64位、系统内核版本为 3.10 以上

查看CentOS版本:lsb_release -a

[root@localhost /]# lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.4.1708 (Core) 
Release:	7.4.1708
Codename:	Core

如果出现“未找到命令”,执行【yum install -y redhat-lsb】进行安装

查看系统内核版本:uname -r

[root@localhost /]# uname -r
3.10.0-693.el7.x86_64

检查是否已安装docker:yum list installed | grep docker,无提示,说明没有安装

2. 安装

安装docker:yum -y install docker

安装完毕之后,执行【yum list installed | grep docker】可看到下面的信息:

[root@localhost /]# yum list installed | grep docker
docker.x86_64                          2:1.13.1-209.git7d71120.el7.centos
docker-client.x86_64                   2:1.13.1-209.git7d71120.el7.centos
docker-common.x86_64                   2:1.13.1-209.git7d71120.el7.centos
3. 启动

启动docker:systemctl start docker

检查docker是否启动成功:systemctl status docker

[root@localhost /]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 一 2023-09-04 10:09:10 CST; 12s ago
     Docs: http://docs.docker.com
 Main PID: 3037 (dockerd-current)
   CGroup: /system.slice/docker.service
           ├─3037 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/us...
           └─3043 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-...

9月 04 10:09:08 localhost dockerd-current[3037]: time="2023-09-04T10:09:08.837909660+08:00" level=info msg="libcontainerd: new containerd process, pid: 3043"
9月 04 10:09:09 localhost dockerd-current[3037]: time="2023-09-04T10:09:09.949411981+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
9月 04 10:09:09 localhost dockerd-current[3037]: time="2023-09-04T10:09:09.950494563+08:00" level=info msg="Loading containers: start."
9月 04 10:09:09 localhost dockerd-current[3037]: time="2023-09-04T10:09:09.970314283+08:00" level=info msg="Firewalld running: true"
9月 04 10:09:10 localhost dockerd-current[3037]: time="2023-09-04T10:09:10.155367538+08:00" level=info msg="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"
9月 04 10:09:10 localhost dockerd-current[3037]: time="2023-09-04T10:09:10.331771310+08:00" level=info msg="Loading containers: done."
9月 04 10:09:10 localhost dockerd-current[3037]: time="2023-09-04T10:09:10.345784207+08:00" level=info msg="Daemon has completed initialization"
9月 04 10:09:10 localhost dockerd-current[3037]: time="2023-09-04T10:09:10.345826141+08:00" level=info msg="Docker daemon" commit="7d71120/1.13.1" graphdriver=overlay2 version=1.13.1
9月 04 10:09:10 localhost dockerd-current[3037]: time="2023-09-04T10:09:10.351121710+08:00" level=info msg="API listen on /var/run/docker.sock"
9月 04 10:09:10 localhost systemd[1]: Started Docker Application Container Engine.

以上出来的Active(running)说明docker安装成功。

设置Docker服务开机自启:systemctl enable docker.service

[root@localhost /]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

你可能感兴趣的:(linux,运维,服务器)