一、yum安装docker(CentOS 7)
- Docker CE 即社区免费版,Docker EE 即企业版,强调安全,但需付费使用。
- 下面是Docker CE的安装使用
-
移除旧的版本:
$ 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
-
安装一些必要的系统工具:
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
-
添加软件源信息:
$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
-
更新 yum 缓存:
$ sudo yum makecache fast
-
安装 Docker-ce:
$ sudo yum -y install docker-ce
-
启动 Docker 后台服务
$ sudo systemctl start docker
-
测试运行 hello-world
[root@localhost docker]# docker run hello-world 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/
二、使用脚本安装 Docker
-
使用 sudo 或 root 权限登录 Centos。
-
确保 yum 包更新到最新。
$ sudo yum update
-
执行 Docker 安装脚本。
$ curl -fsSL https://get.docker.com -o get-docker.sh $ sudo sh get-docker.sh
- 执行这个脚本会添加 docker.repo 源并安装 Docker。
-
启动 Docker 进程
$ sudo systemctl start docker
-
验证 docker 是否安装成功并在容器中执行一个测试的镜像。
$ sudo docker run hello-world
三、镜像加速
- 可以去 https://www.daocloud.io/ 注册,配置专有的镜像地址
四、删除 Docker CE
-
执行以下命令来删除 Docker CE:
$ sudo yum remove docker-ce $ sudo rm -rf /var/lib/docker
本文由 bytebye 创作
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:
2018/11/16 11:04