dockerfile创建镜像1

vim Dockerfile

1
2
3
FROM alpine:latest
MAINTAINER brady
CMD echo "hello world"

 进行构建

docker build -t hello_docker .

 

复制代码
[root@localhost dnmp_test]# ls
[root@localhost dnmp_test]# vim Dockerfile
[root@localhost dnmp_test]# docker build -t hello_docker .
Sending build context to Docker daemon 2.048 kB
Step 1/3 : FROM alpine:latest
Trying to pull repository docker.io/library/alpine ...
latest: Pulling from docker.io/library/alpine
9d48c3bd43c5: Pull complete
Digest: sha256:72c42ed48c3a2db31b7dafe17d275b634664a708d901ec9fd57b1529280f01fb
Status: Downloaded newer image for docker.io/alpine:latest
 ---> 961769676411
Step 2/3 : MAINTAINER brady

▽
 ---> Running in f1802f56a693
 ---> 00cdf7104f8b
Removing intermediate container f1802f56a693
Step 3/3 : CMD echo "hello world"
 ---> Running in e7b7a18d8c32
 ---> baa4664fe58d
Removing intermediate container e7b7a18d8c32
Successfully built baa4664fe58d
[root@localhost dnmp_test]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello_docker        latest              baa4664fe58d        6 seconds ago       5.58 MB
nginx-fun           latest              6ea0e8bb024d        7 minutes ago       126 MB
docker.io/nginx     latest              ab56bba91343        8 days ago          126 MB
docker.io/alpine    latest              961769676411        4 weeks ago         5.58 MB
[root@localhost dnmp_test]# docker run hello_docker
hello world
复制代码

 推送到远程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
[root@localhost docker]# ls
Dockerfile
[root@localhost docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello_docker        latest              c4ea4dd5f8f9        2 minutes ago       5.59MB
alpine              latest              e7d92cdc71fe        5 weeks ago         5.59MB
[root@localhost docker]# docker commit -a brady -m "hello docker" c4ea4dd5f8f9 yeves/hello_docker
Error response from daemon: No such container: c4ea4dd5f8f9
[root@localhost docker]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@localhost docker]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                   CREATED             STATUS                     PORTS               NAMES
59d586c17da1        hello_docker        "/bin/sh -c 'echo \"h…"   2 minutes ago       Exited (0) 2 minutes ago                       musing_shamir
9b8fe3409f62        hello_docker        "/bin/sh -c 'echo \"h…"   2 minutes ago       Exited (0) 2 minutes ago                       festive_nightingale
[root@localhost docker]# docker commit -a brady -m "hello docker" 59d586c17da1  yeves/hello_docker
sha256:315c59b50d02e0617d9249300f0f2f54fb929d4dcda124e71a07c87864455bcc
[root@localhost docker]# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
yeves/hello_docker   latest              315c59b50d02        6 seconds ago       5.59MB
hello_docker         latest              c4ea4dd5f8f9        3 minutes ago       5.59MB
alpine               latest              e7d92cdc71fe        5 weeks ago         5.59MB
[root@localhost docker]# 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: yeves
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
 
Login Succeeded
[root@localhost docker]# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
yeves/hello_docker   latest              315c59b50d02        49 seconds ago      5.59MB
hello_docker         latest              c4ea4dd5f8f9        4 minutes ago       5.59MB
alpine               latest              e7d92cdc71fe        5 weeks ago         5.59MB
[root@localhost docker]# docker tag 315c59b50d02 yeves/hellow_docker:v1.0
[root@localhost docker]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED              SIZE
yeves/hello_docker    latest              315c59b50d02        About a minute ago   5.59MB
yeves/hellow_docker   v1.0                315c59b50d02        About a minute ago   5.59MB
hello_docker          latest              c4ea4dd5f8f9        4 minutes ago        5.59MB
alpine                latest              e7d92cdc71fe        5 weeks ago          5.59MB
[root@localhost docker]# docker push yeves/hello_docker:v1.0
The push refers to repository [docker.io/yeves/hello_docker]
tag does not exist: yeves/hello_docker:v1.0
[root@localhost docker]#

  

posted @   brady-wang  阅读(278)  评论(0编辑  收藏  举报
编辑推荐:
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
· .NET 适配 HarmonyOS 进展
阅读排行:
· 如何给本地部署的DeepSeek投喂数据,让他更懂你
· 超详细,DeepSeek 接入PyCharm实现AI编程!(支持本地部署DeepSeek及官方Dee
· 用 DeepSeek 给对象做个网站,她一定感动坏了
· .NET 8.0 + Linux 香橙派,实现高效的 IoT 数据采集与控制解决方案
· DeepSeek处理自有业务的案例:让AI给你写一份小众编辑器(EverEdit)的语法着色文件
历史上的今天:
2018-09-21 爬虫学习之-可视化函数
2018-09-21 python response.text和response.content的区别
2018-09-21 python 创建目录
2018-09-21 git因commit的记录太大导致push失败解决方法
2018-09-21 爬虫学习之-git拉取远程错误
2017-09-21 测试jsonp
2017-09-21 测试openssl_encrypt
点击右上角即可分享
微信分享提示