虚拟机CentOS7上安装Docker踩坑记录

在VMWare得CentOS虚拟机中
虚拟机名字:CentOS 7 64位
安装教程参考尚硅谷Springcloud教程资料实用篇Day3

1.循环报错

已加载插件:fastestmirror, langpacks
/var/run/yum.pid 已被锁定,PID 为 3239 的另一个程序正在运行。
Another app is currently holding the yum lock; waiting for it to exit...
  另一个应用程序是:PackageKit
    内存: 28 M RSS (1.4 GB VSZ)
    已启动: Mon Apr 25 10:36:15 2022 - 00:10之前
    状态  :睡眠中,进程ID:3239
Another app is currently holding the yum lock; waiting for it to exit...
  另一个应用程序是:PackageKit
    内存: 28 M RSS (1.4 GB VSZ)
    已启动: Mon Apr 25 10:36:15 2022 - 00:12之前
    状态  :睡眠中,进程ID:3239
Another app is currently holding the yum lock; waiting for it to exit...
  另一个应用程序是:PackageKit
    内存: 28 M RSS (1.4 GB VSZ)
    已启动: Mon Apr 25 10:36:15 2022 - 00:14之前
    状态  :睡眠中,进程ID:3239
Another app is currently holding the yum lock; waiting for it to exit...
  另一个应用程序是:PackageKit
    内存: 28 M RSS (1.4 GB VSZ)
    已启动: Mon Apr 25 10:36:15 2022 - 00:16之前
    状态  :睡眠中,进程ID:3239

原因:
/var/run/yum.pid被锁定
解决方法:
先输入ctrl+C停止运行,然后输入命令rm -f /var/run/yum.pid

2.启动docker前先关闭防火墙

# 关闭
systemctl stop firewalld
# 禁止开机启动防火墙
systemctl disable firewalld
[root@node01 ~]# systemctl stop firewalld
[root@node01 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@node01 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead) since 一 2022-04-25 10:47:10 CST; 27s ago
     Docs: man:firewalld(1)
 Main PID: 875 (code=exited, status=0/SUCCESS)

425 10:34:09 node01 systemd[1]: Starting firewalld - dynamic firewall daemon...
425 10:34:15 node01 systemd[1]: Started firewalld - dynamic firewall daemon.
425 10:47:08 node01 systemd[1]: Stopping firewalld - dynamic firewall daemon...
425 10:47:10 node01 systemd[1]: Stopped firewalld - dynamic firewall daemon.

3.启动和确认状态

[root@node01 ~]# systemctl start docker
[root@node01 ~]# systemctl status docker

查看版本:docker -v

4.docker打包和拉取镜像命令

命令:
下载nginx镜像:[root@node01 ~]# docker pull nginx
查看镜像信息:[root@node01 ~]# docker images

[root@node01 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    605c77e624dd   3 months ago   141MB

打包镜像到磁盘中:[root@node01 ~]# docker save -o nginx.tar nginx:latest
删除镜像:[root@node01 ~]# docker rmi nginx:latest
拉取镜像:[root@node01 ~]# docker load -i nginx.tar

你可能感兴趣的:(docker)