WIN10安装docker笔记(使用代理)

1.docker官网下载docker

2.双击安装,如果不是管理员用户,可安装后在给该用户赋权,赋权方法:用管理员账号登录电脑,右键我的电脑--管理--用户和组-组-双击docker-user-添加自己的账号-应用即可

3.用自己的账号登录win,打开docker,电脑托盘处,右键docker-setting,

1)配置general,全部去掉打钩

2)如果你的电脑使用了代理:配置resources-配置proxies-前两个填写你的代理地址,格式如下http://用户名:密码@IP:端口

3)配置network-打开DNS

4.配置完成

5.运行cmd,即可运行docker命令,拉取镜像docker pull centos:centos7

6.查看镜像命令docker images---运行镜像命令docker run -d -i -t镜像ID /bin/bash

进入镜像命令docker attach 容器ID

7.如果你的电脑使用了代理,centos中的yum会报错,所以yum需要单独配置代理

8.yum配置代理方法:

vi /etc/yum.conf

proxy=http://xxx.xxx.xxx.xxx:xxxx

proxy_username=用户名

proxy_password=密码

9.然后更改你的yum源,进入/etc/yum.repos.d,删除CentOS-Base.repo外的其他所以文件,然后编辑改文件,:%d删除全部内容,用如下内容替换(下面是清华的源,你可以使用阿里等其他的源)

# CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update status of each mirror to pick mirrors that are updated to and# geographically close to the client.You should use this for CentOS updates# unless you are manually picking other mirrors.## If the mirrorlist= does not work for you, as a fall back you can try the# remarked out baseurl= line instead.##[base]name=CentOS-$releasever - Basebaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7#released updates[updates]name=CentOS-$releasever - Updatesbaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7#additional packages that may be useful[extras]name=CentOS-$releasever - Extrasbaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extrasenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7#additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plusbaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplusgpgcheck=0enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7

10.到此docker中centos就可以愉快的使用了

11.点赞无bug,谢谢