【centos7】安装docker
程序员文章站
2022-05-31 11:05:11
...
下面是安装docker-communtiy版本的方法。
1. 清除可能存在的老版本
$ 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
2. 下载rpm文件
- containerd.io-1.2.0-3.el7.x86_64.rpm
- docker-ce-cli-18.09.0-3.el7.x86_64.rpm
- docker-ce-18.09.0-3.el7.x86_64.rpm
下载页面: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
分别对如上文件进行安装
sudo yum install containerd.io-1.2.0-3.el7.x86_64.rpm
sudo yum install docker-ce-cli-18.09.0-3.el7.x86_64.rpm
sudo yum install docker-ce-18.09.0-3.el7.x86_64.rpm
3. 设置docker deamon自启动
[[email protected] ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
4. 镜像加速
国内连接Docker hub网络情况不佳,我们可以考虑国内提供加速服务的公司,目前有阿里云和daoCloud的加速,下面已daocloud的镜像加速为例。
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
该脚本可以将 --registry-mirror 加入到你的 Docker 配置文件 /etc/docker/daemon.json 中。适用于 Ubuntu14.04、Debian、CentOS6 、CentOS7、Fedora、Arch Linux、openSUSE Leap 42.1,其他版本可能有细微不同。更多详情请访问文档。
5. 启动Docker
systemctl start docker
6. 示例
[[email protected] docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:523e382ab1801f2a616239b1052bb7ee5a7cce6a06cfed27ccb93680eacad6ef
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/
推荐阅读
-
Windows下PHP5和Apache的安装与配置_PHP
-
Windows 安装 MySQL 8.0.11
-
CentOS7中防火墙的一些常用配置介绍
-
fedora源码安装opencv3.4.1
-
TFTP安装与配置
-
CentOS 7 x64下Apache+MySQL(Mariadb)+PHP56的安装教程详解
-
Linux系统下安装rz/sz命令及使用说明(详解)
-
MIKE ZERO 2014怎么安装?MIKE ZERO 2014 SP3安装破解图文详细教程
-
SystemVue 2018安装破解激活+中文汉化图文详细教程(附下载)
-
TestTrack Pro怎么安装?TestTrack Pro安装配置详细图文教程