Docker+gitlab+jenkins实现项目自动部署

一、Docker安装(CentOS)

1、准备工作

系统要求

以下为官网原文

To install Docker Engine, you need a maintained version of CentOS 7 or 8. Archived versions aren’t supported or tested.

The centos-extras repository must be enabled. This repository is enabled by default, but if you have disabled it, you need to re-enable it.

The overlay2 storage driver is recommended.

Docker 支持 64 位版本 CentOS 7/8,并且要求内核版本不低于 3.10。 CentOS 7 满足最低内核的要求,但由于内核版本比较低,部分功能(如 overlay2 存储层驱动)无法使用,并且部分功能可能不太稳定。

卸载旧版本

旧版本的Docker被称为Docker或Docker -engine。 如果安装了这些组件,运行以下命令进行卸载:

$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine
复制代码

CentOS8额外设置

由于 CentOS8 防火墙使用了 nftables,但 Docker 尚未支持 nftables, 我们可以使用如下设置使用 iptables

更改 /etc/firewalld/firewalld.conf

# FirewallBackend=nftables
FirewallBackend=iptables
复制代码

2、使用仓库方式进行安装

设置仓库

在新主机上首次安装Docker引擎之前,需要设置Docker仓库。安装yum-utils包(用到yum-config-manager工具)并设置仓库,鉴于国内网络问题,强烈建议使用国内源,官方源请在注释中查看。

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

# 官方源
# $ sudo yum-config-manager \
#     --add-repo \
#     https://download.docker.com/linux/centos/docker-ce.repo
复制代码

如果需要测试版本的 Docker 请执行以下命令:

$ sudo yum-config-manager --enable docker-ce-test
复制代码

安装Docker引擎

安装最新版本的Docker Engine和容器

$ sudo yum install docker-ce docker-ce-cli containerd.io
复制代码

3、启动Dokcer

$ sudo systemctl enable docker
$ sudo systemctl start docker
复制代码

4、测试Docker安装是否正确

$ docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f6
  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值