docker里面没有sysctl_CentOS下使用Docker常见问题及处理方法

在使用Docker的过程中会遇到各种各样的问题,下面是CentOS下使用Docker部分常见问题及处理方法的简单汇总,供参考。

1、CentOS下安装Docker

一般不建议使用系统yum源来安装,因为CentOS软件仓库里的docker版本太旧;

源码安装步骤稍显复杂,不适合初学者;

如果没有特殊需求,通常建议安装最新的Docker稳定版本,在线安装时需要先安装docker官方的yum配置包:

SET UP THE REPOSITORY

Install the yum-utils package (which provides the yum-config-manager utility) and set up the stable repository.

$ sudo yum install -y yum-utils$ sudo yum-config-manager \--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

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

如果是离线安装,可以参考:

(1)CentOS7离线安装docker最新稳定版

(2)CentOS8上离线安装Docker最新稳定版

2、容器开机自启动的实现

首先需要保证docker服务本身是自启动的;

其次是创建容器时加上参数--restart=always(这个最常用),例如:

docker run -d --name Redis --restart=always -p 6379:6379 redis

如果创建时未指定 --restart=always,可通过update命令追加:

docker update --restart=always xxx

使用--restart=always要注意:务必在验证容器能正常启动后再添加此参数,不然创建容器后不断重启可能影响问题排查。

官方说明:

Use a restart policy

To configure the restart policy for a container, use the --restart flag when using the docker run command. The value of the --restart flag can be any of the following:

Flag        Description

no            --Do not automatically restart the container. (the default)

on-failure --Restart the container if it exit

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值