CentOS6.x 安装 Docker

Docker 官方要求要 CentOS7.0 及以上系统版本,但是有时候不能为了安装Docker就把稳定运行的服务器升级系统版本,还是需要在已有的 CentOS6.x 的系统上进行安装。

比如之前Memcached爆出的UDP11211的bug时,直接在原系统中升级Memcached版,很麻烦,需要各种编译,安装Docker是很快速方便的解决方案,但是看到CentOS6.x,瞎了。。同时安装Docker以后升级Memcached版本也是方便加愉快的事情,^_^

SO,研究了下怎么在CentOS6.x下安装Docker

参考https://www.liquidweb.com/kb/how-to-install-docker-on-centos-6/

1.安装EPEL仓库

rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

2.更新

yum update -y

3.安装

yum -y install docker-io

4.安装完后启动

service docker start

5.设置开机启动

chkconfig docker on

6.使用docker

docker pull xxxx

 

以上你就可以在CentOS6.x中使用Docker了

 

 

创建Docker镜像并提交至DockerHub

创建Docker镜像(Commit方式实现打包)

Commit方式打包镜像是一种方式,还可使用Dockerfile 自动编译生成

使用命令 docker ps查看当前运行的Docker容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b02555261b2a ccr.ccs.tencentyun.com/nginx:2 "docker-php-entrypoin" 6 minutes ago Up 6 minutes k8s_nginx.74ee725_nginx-1995117297-oawi1_default_7dbcfe76-61f3-11e7-b1ab-5254009c3093_59ad5c81

使用docker commit b02555261b2a lifeng198931/nginx-php:1.0 创建镜像   b02555261b2a 为CONTAINER ID

创建成功返回
sha256:6a3e4eb482d4ecf8bdd7fdcd015e06c81c7795f97ba8ed040bba63e42115fb2e

使用docker images查看打包好的镜像
REPOSITORY                   TAG IMAGE ID CREATED SIZE
lifeng198931/nginx-php 1.0 6a3e4eb482d4 5 seconds ago 552.8 MB

提交镜像

提交镜像至DockerHub需要有Docker-Hub账号,注册地址:https://hub.docker.com/

执行登录命令:docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: lifeng198931
Password:
Login Succeeded

输入命令docker tag 6a3e4eb482d4 lifeng198931/nginx-php:1.0    (PS:6a3e4eb482d4 为IMAGE ID)

最后执行PUSH操作docker push lifeng198931/nginx-php:1.0

稍等即Push成功

The push refers to a repository [docker.io/lifeng198931/nginx-php]
268b8c9b1604: Pushed
17486fcba291: Pushed
8ff73332a9c1: Pushing [===========================> ] 155.3 MB/280 MB
aa204764cc4c: Pushed
57f2e59a32ca: Pushed
e62d186aa9be: Pushed
284ace007aa5: Pushed
c218504836c2: Pushed
8a4b1177628d: Pushed
e5997bcc7786: Pushed
a976f44b8bbe: Pushed
4e3fe34ea5e3: Pushed
361b51002dab: Pushed
4195f36f22b0: Pushed
9c9c7359c814: Pushed
3378f970b72b: Pushed
6fc3d03cebe5: Pushed
d8d476202fd7: Pushed
26512ae4e602: Pushed
860dad618727: Pushing [=============================================> ] 140.8 MB/155.7 MB
ba7c41d37d48: Pushed
ce85b98da8c7: Pushed
8b67277fe14c: Pushed
777815bf4018: Pushed
772310149819: Pushed
f523e6e77276: Pushed
5fac08f9b8ad: Pushed
3c9c7a962414: Pushed
9b0b7ab4f5b2: Pushed
2acb0f8e8be6: Pushed
5accac14015f: Pushed

1.0: digest: sha256:5043476a7e803221c6a303bcfe989488b558365f618789c14ec8109d833b19d2 size: 6780

最后显示这个即PUSH成功

最后上https://hub.docker.com/r/lifeng198931/nginx-php/tags/查看