curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh
useradd docker
adduser docker
adduser -g docker
adduser -g docker docker
passwd docker
sudo usermod -aG docker docker
sudo systemctl enable docker
Docker开启远程访问
Linux centos 版本3.10.0-514.el7.x86_64(uname-r)
关闭防火墙:
systemctl stop firewalld.service
查看防火墙的状态
service firewalld status; #查看防火墙状态
修改以ExecStart开头的行:(因为我的系统是centos 7的,所以修改为下面得)
首先编辑docker的宿主机文件
vim/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd-Hfd:// -H tcp://0.0.0.0:2375
修改后保存文件,然后通知docker服务做出的修改
systemctl daemon-reload
重启docker服务
service docker restart
接下来测试一下看是否能连接到docker api。上面的2375就是对应端口
curlhttp://localhost:2375/verion
Docker容器连接外部网络
默认通过桥接方式
[https://docs.docker.com/network/bridge/](https://docs.docker.com/network/bridge/)
vim /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward = 1
重启宿主机:
service docker restart
Registry 仓库安装
vim /etc/default/docker
DOCKER_OPTS="--insecure-registry 172.23.23.87:5000"
二、使用rpm包安装
如果你不能使用docker的镜像仓库,你可以下载.rpm文件,然后手动安装。
1、进入 https://download.docker.com/linux/centos/7/x86_64/stable/Packages/ 页面,下载要安装Docker版本的.rpm文件
2、安装Docker
$ sudo yum install docker.rpm
3、启动doker
$ sudo systemctl start docker
4、通过运行hello-world镜像验证安装是否成功
$ sudo docker run hello-world
卸载Docker
1、卸载Docker安装包
$ sudo yum remove docker-ce
image.gif
2、此操作不会删除你电脑上的镜像,容器,卷和自定义配置文件,如果想删除可以用以下命令
sudo rm -rf /var/lib/docker
原文链接:https://blog.csdn.net/u011936655/article/details/81062343</pre>
网友评论