Linux下安装Docker

在2017年的3月1号之后,Docker的版本命名分为CE(Community Edition,社区版)版本和EE(Enterprise Edition,企业版)版本。我们使用CE版本就够了。
基本主流的操作系统都可以安装。
我非常建议大家在Linux下安装,而不是在Windows下,因为Linux版Docker是企业生产用的。

1.CentOS

官方安装文档: https://docs.docker.com/install/linux/docker-ce/centos/
**
服务器的系统是CentOS7.4的**
[root@VM_82_178_centos ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

#安装依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2
#添加Docker软件包源
yum-config-manager
–add-repo
 https://download.docker.com/linux/centos/docker-ce.repo
#安装Docker CE
yum install docker-ce -y
#启动
systemctl start docker
#开机启动
systemctl enable docker
#查看Docker信息
docker info

2.Ubuntu 上安装

apt-get update
安装证书:

apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

添加docker源的key:

sudo apt-key fingerprint 0EBFCD88

pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

添加docker软件包源:

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  • 1.
  • 2.
  • 3.
  • 4.

跟新apt包索引:
sudo apt-get update

安装docker ce
apt-get install docker-ce

3.配置Docker加速器

Docker Hub 提供众多镜像,你可以从中自由下载数十万计的免费应用镜像, 这些镜像作为 docker 生态圈的基石,是我们使用和学习 docker 不可或缺的资源。为了解决国内用户使用 Docker Hub 时遇到的稳定性及速度问题 DaoCloud 推出永久免费的新一代加速器服务。
Linux:

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://bc437cce.m.daocloud.io
  • 1.
[root@localhost ~]#  curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://bc437cce.m.daocloud.io
docker version >= 1.12
{"registry-mirrors": ["http://bc437cce.m.daocloud.io"]}
Success.
You need to restart docker to take effect: sudo systemctl restart docker 
[root@localhost ~]# 
[root@localhost ~]# systemctl  restart docker
[root@localhost ~]# systemctl  stop docker
[root@localhost ~]# ps -ef|grep docker
root      15185   3300  0 01:39 pts/1    00:00:00 grep --color=auto docker
[root@localhost ~]# systemctl  start docker
[root@localhost ~]# ps -ef|grep docker
root      15191      1  2 01:39 ?        00:00:00 /usr/bin/dockerd
root      15198  15191  0 01:39 ?        00:00:00 docker-containerd --config /var/run/docker/containerd/containerd.toml
root      15325   3300  0 01:39 pts/1    00:00:00 grep --color=auto docker
[root@localhost ~]#
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
posted @   勤奋的蓝猫  阅读(9)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
点击右上角即可分享
微信分享提示