在Centos7上部署Docker

先判断您的Centos内核版本是否大于 3.10(因为会存在兼容性问题)

	uname -r

输入以下命令来安装docker:

1. yum install -y #更新该Liunx系统的内核版本。
2. yum -y install docker #安装docker
3. systemctl start docker #启动doker服务

如果启动服务时出现了以下信息:
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
可以进行以下操作:

	vi /etc/sysconfig/docker-storage

修改配置文件为:

DOCKER_STORAGE_OPTIONS="--selinux-enabled --log-driver=journald --signature-verification=false"

接着配置以下参数

	vi /etc/docker/daemon.json
{
	"storage-driver": "devicemapper", 
	"registry-mirrors": ["https://aj2rgad5.mirror.aliyuncs.com"] //设置镜象
}
1. systemctl daemon-reload #重载daemon文件
2. systemctl restart docker #重启docker服务

运行完以上命令后,若没有报错,则表示配置成功。

开放管理端口映射

1. vi /lib/systemd/system/docker.service
2. 找到 ExecStart=/usr/bin/dockerd-current 并改为:
	ExecStart=/usr/bin/dockerd-current -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:7654
	
	其中 2375 为管理端口,7654 为备用端口
	
3. vi  ~/.bashrc #写入 2375 管理端口号
	
	尾部添加: export DOCKER_HOST=tcp://0.0.0.0:2375
	
4. source ~/.bashrc #重载 .bashrc 文件

重启docker服务

	systemctl restart docker.service

测试是否安装成功并正确运行

	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/
则表示一切都 ok了。

本文参考:

  1. 链接:https://blog.csdn.net/u010046908/article/details/79553227
  2. 链接:https://blog.csdn.net/YooFale/article/details/84900712
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值