创建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/查看