Docker 安装

下载docker-engine-1.13.1-1.el7.centos.x86_64.rpm 或 在线安装

 wget https://yum.dockerproject.org/repo/main/centos/7/Packages/docker-engine-1.13.1-1.el7.centos.x86_64.rpm
 yum -y localinstall docker-engine-1.13.1-1.el7.centos.x86_64.rpm
 

或者

 yum -y install https://yum.dockerproject.org/repo/main/centos/7/Packages/docker-engine-1.13.1-1.el7.centos.x86_64.rpm

启动

service docker start

添加代理配置并重启

mkdir -p  /etc/systemd/system/docker.service.d
vim  /etc/systemd/system/docker.service.d/http-proxy.conf

添加以下代理配置项

[Service]
Environment="HTTP_PROXY=http://xx:913" "HTTPS_PROXY=http://xx:913" "NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24, *.xx.com, 10.239.47.*, *.sh.xx.com"
使配置生效
systemctl daemon-reload
systemctl restart docker
verify 配置
# systemctl show --property=Environment docker
Environment=HTTP_PROXY=http://xx.com:port HTTPS_PROXY=http://xx.com:port NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24,\x20*.xx.com,\x2010.239.47.*,\x20*.sh.xx.com

验证docker安装成功与否

docker run hello-world

# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ... 
/usr/bin/docker-current: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: net/http: TLS handshake timeout.
See '/usr/bin/docker-current run --help'.

遇到上面的问题,可能是网络延迟问题,可再执行第二次

# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
Status: Downloaded newer image for hello-world:latest

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/

下载一个image 并运行

无需登陆zhixingheyitian
注意要映射一个还没被占用的端口

# docker run -p 8089:8080 -d zhixingheyitian/kubia
Unable to find image 'zhixingheyitian/kubia:latest' locally
latest: Pulling from zhixingheyitian/kubia
ad74af05f5a2: Pull complete 
2b032b8bbe8b: Pull complete 
a9a5b35f6ead: Pull complete 
3245b5a1c52c: Pull complete 
afa075743392: Pull complete 
9fb9f21641cd: Pull complete 
3f40ad2666bc: Pull complete 
49c0ed396b49: Pull complete 
e8185acbed35: Pull complete 
Digest: sha256:108ae1932e7093ed73a6a36303a8fde8bbfef776b40406343e92b8596910a375
Status: Downloaded newer image for zhixingheyitian/kubia:latest
3325e8018905ac4b3bd22605e0bfb3507d4e49f523f63610f93a6d02e6f1bc09
验证container服务
# curl localhost:8089
You've hit 48d6d564e2b1

如果宿主机设置了 proxy, 可以这样检测服务

# curl --noproxy '*' localhost:8089
You've hit 48d6d564e2b1
pull 亦无需登陆
# docker pull zhixingheyitian/spark:spark2.4.1
spark2.4.1: Pulling from zhixingheyitian/spark
8e402f1a9c57: Pull complete 
4866c822999c: Pull complete 
ec484ea07ed1: Pull complete 
c99b7b28847d: Pull complete 
8243ae0d4e12: Pull complete 
804abac0811f: Pull complete 
e19825f5e965: Pull complete 
c85e68151dfd: Pull complete 
892a3960d555: Pull complete 
bbde6b6686fc: Pull complete 
cea92489f973: Pull complete 
Digest: sha256:8f08f90c68a5c4806f6ba57d1eb675c239d6fd96ca7c83cec1b6fe0d1ff25d06
Status: Downloaded newer image for zhixingheyitian/spark:spark2.4.1

卸载 docker

先列出

# yum list installed | grep docker
docker-client.x86_64               2:1.13.1-94.gitb2f74b2.el7.centos @extras    
docker-common.x86_64               2:1.13.1-94.gitb2f74b2.el7.centos @extras

再逐一删除

# yum remove -y docker-client.x86_64
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package docker-client.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos will be erased
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
 Package                                                Arch                                            Version                                                                      Repository                                        Size
============================================================================================================================================================================================================================================
Removing:
 docker-client                                          x86_64                                          2:1.13.1-94.gitb2f74b2.el7.centos                                            @extras                                           13 M

Transaction Summary
============================================================================================================================================================================================================================================
Remove  1 Package

Installed size: 13 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 2:docker-client-1.13.1-94.gitb2f74b2.el7.centos.x86_64                                                                                                                                                                   1/1 
  Verifying  : 2:docker-client-1.13.1-94.gitb2f74b2.el7.centos.x86_64                                                                                                                                                                   1/1 

Removed:
  docker-client.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos                                                                                                                                                                                    

Complete!
[root@sr533 k8s]# yum remove -y docker-common.x86_64
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package docker-common.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos will be erased
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
 Package                                                Arch                                            Version                                                                      Repository                                        Size
============================================================================================================================================================================================================================================
Removing:
 docker-common                                          x86_64                                          2:1.13.1-94.gitb2f74b2.el7.centos                                            @extras                                          4.4 k

Transaction Summary
============================================================================================================================================================================================================================================
Remove  1 Package

Installed size: 4.4 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 2:docker-common-1.13.1-94.gitb2f74b2.el7.centos.x86_64                                                                                                                                                                   1/1 
  Verifying  : 2:docker-common-1.13.1-94.gitb2f74b2.el7.centos.x86_64                                                                                                                                                                   1/1 

Removed:
  docker-common.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos                                                                                                                                                                                    

Complete!

清理相关目录

rm -rf /var/lib/docker

删除本地images

docker rmi zhixingheyitian/spark:spark2.4.1-ocp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值