因网络原因现在不能直接下载docker hub上的镜像,通过proxy设置访问。
一、测试环境。
proxy软件在笔记本上使用c;192.168.253.1,proxy端口8888。下载docker镜像,搭建Linux虚拟机c;虚拟IP192.168.253.129。
二、修改docker配置文件。
在虚拟机中修改docker配置文件/lib/systemd/system/docker.service,指向代理服务程序端口。
需要在Service小段中添加:
Environment="HTTP_PROXY=http://192.168.253.1:8888"
Environment="HTTPS_PROXY=http://192.168.253.1:8888"以下:
[root@localhost ~]# vi /lib/systemd/system/docker.service[root@localhost ~]# cat /lib/systemd/system/docker.service[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network-online.target firewalld.serviceWants=network-online.target[Service]Type=notifyEnvironment="HTTP_PROXY=http://192.168.253.1:8888"Environment="HTTPS_PROXY=http://192.168.253.1:8888"EnvironmentFile=-/etc/sysconfig/dockerEnvironmentFile=-/etc/sysconfig/docker-storageEnvironmentFile=-/etc/sysconfig/docker-networkEnvironment=GOTRACEBACK=crashExecStart=/usr/bin/dockerd $OPTIONS \ $DOCKER_STORAGE_OPTIONS \ $DOCKER_NETWORK_OPTIONS \ $INSECURE_REGISTRYExecReload=/bin/kill -s HUP $MAINPIDLimitNOFILE=104876LimitNPRO=104876LimitCORE;infinity# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process[Install]WantedBy=multi-user.target。
三、验证重启服务。
[root@localhost ~]# systemctl daemon-reload[root@localhost ~]# systemctl restart docker [root@localhost ~]# docker pull minio/minio:latest latest: Pulling from minio/minio5360c0b72d: Pull complete f2f8f30a646a: Pull complete 4fc5fcb7e9: Pull complete 53140b7a7f04: Pull complete 2b8c182be72c: Pull complete 4363be478988: Pull complete de7c323e2901: Pull complete 7eb10b7b511b: Pull complete 3d82d69301e2: Pull complete Digest: sha256:cd04ea408cf185cb5007ea1c398d44419b19aaaae15aaab4537cccf14b2a2f86statatus: Downloaded newer image for minio/minio:latest[root@localhost ~]#。
你可以看到容器镜像已能正常下载c;也可以参考使用网络proxy的配置。
你可以看到容器镜像已能正常下载c;也可以参考使用网络proxy的配置。 顶: 351踩: 6
评论专区