centos7 linux搭建docker环境

docker越来越流行,掌握容器技术,现在已经显得越来越重要

下面介绍一下如何在centos上搭建自己的docker

1、需要安装一下依赖

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

2、添加软件源信息

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

3、开始更新并安装docker

sudo yum install docker-ce docker-ce-cli containerd.io

4、安装完毕以后,运行docker run hello-world测试一下,如果出现一下信息,表示docker环境搭建完成

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1
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/

注意:虽然环境搭建完毕了,但是每次拉取镜像都要从国外的网站进行拉取的话,速度是比较慢的,这里把镜像源进行更改一下

我使用的是阿里云的镜像加速器,配置方法如下:

1、需要有一个阿里云的账号,登录阿里云点击控制台

按照如下操作,一次点击,在第三步输入镜像进行检索,点击容器镜像服务

进入镜像服务后,进行如下操作

在/etc/目录下创建一个docker的目录

mkdir /etc/docker

2、执行如下代码

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["添加你自己的加速器地址"]
}
EOF

然后执行第5步骤,阿里云的镜像加速就配置完成了,接下来你就可以开始自己的docker开发了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值