docker镜像创建
1. 首选要创建一个Dockerfile文件,内容如下:
FROM alpine:latest
MAINTAINER lobin <lobin.hotmail.com>
RUN apk add --no-cache --update-cache bash
CMD ["/bin/bash"]
2. 生成镜像,取名apline-bash
[root@VM_0_13_centos demo]# docker build -t apline-bash .
Sending build context to Docker daemon 2.048 kB
Step 1/4 : FROM alpine:latest
---> 3fd9065eaf02
Step 2/4 : MAINTAINER lobin <lobin.hotmail.com>
---> [Warning] IPv4 forwarding is disabled. Networking will not work.
---> Running in a73f8500b494
---> 398e9ed5537e
Removing intermediate container a73f8500b494
Step 3/4 : RUN apk add --no-cache --update-cache bash
---> [Warning] IPv4 forwarding is disabled. Networking will not work.
---> Running in dd629be23601
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/main: temporary error (try again later)
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz: temporary error (try again later)
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/community: temporary error (try again later)
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
bash (missing):
required by: world[bash]
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz: temporary error (try again later)
ERROR: unsatisfiable constraints:
The command '/bin/sh -c apk add --no-cache --update-cache bash' returned a non-zero code: 1
3. 出现以上错误,没辙,重启docker能解决,但问题不知道
[root@VM_0_13_centos demo]# systemctl restart docker
4. 重新构建镜像
[root@VM_0_13_centos demo]# docker build -t apline-bash .
Sending build context to Docker daemon 2.048 kB
Step 1/4 : FROM alpine:latest
---> 3fd9065eaf02
Step 2/4 : MAINTAINER lobin <lobin.hotmail.com>
---> Using cache
---> 398e9ed5537e
Step 3/4 : RUN apk add --no-cache --update-cache bash
---> Running in 4ce990201bfd
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/6) Installing pkgconf (1.3.10-r0)
(2/6) Installing ncurses-terminfo-base (6.0_p20171125-r0)
(3/6) Installing ncurses-terminfo (6.0_p20171125-r0)
(4/6) Installing ncurses-libs (6.0_p20171125-r0)
(5/6) Installing readline (7.0.003-r0)
(6/6) Installing bash (4.4.19-r1)
Executing bash-4.4.19-r1.post-install
Executing busybox-1.27.2-r7.trigger
OK: 13 MiB in 17 packages
---> b6ed2497fc7e
Removing intermediate container 4ce990201bfd
Step 4/4 : CMD /bin/bash
---> Running in 61323661705d
---> a7414979d240
Removing intermediate container 61323661705d
Successfully built a7414979d240
[root@VM_0_13_centos demo]#
Message from syslogd@localhost at Jul 4 23:49:17 ...
kernel:unregister_netdevice: waiting for lo to become free. Usage count = 1
Message from syslogd@localhost at Jul 4 23:49:27 ...
kernel:unregister_netdevice: waiting for lo to become free. Usage count = 1
5. 查看镜像,好小呀
[root@VM_0_13_centos demo]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
apline-bash latest a7414979d240 8 minutes ago 9.5 MB
docker.io/redis latest 71a81cb279e3 7 days ago 83.4 MB
docker.io/mysql latest 8d99edb9fd40 7 days ago 445 MB
docker.io/alpine latest 3fd9065eaf02 5 months ago 4.15 MB
转载于:https://www.cnblogs.com/lobin/p/9266090.html
docker镜像创建相关推荐
- docker镜像创建与优化
1 . 创建镜像 有两种方法构建镜像: docker commit :将运行的容器保存成镜像 Dockerfile:自动构建 使用docker commit 创建镜像分为三步: 运行容器 修改容器 将 ...
- Docker镜像创建,拉取以及推送
本篇文章主要讲述如何创建镜像,拉取镜像以及推送镜像到自己的仓库中. 创建镜像 创建镜像有两种方式: docker commit 构建容器 docker build 使用Dockerfile文件来构建 ...
- docker镜像创建及使用
目录 1.创建镜像所在文件夹和Dockerfile文件 2.创建镜像 3.根据创建好的镜像中创建容器 4.docker cp :用于容器与主机之间的数据拷贝 创建镜像[使用Dockerfile] 1. ...
- docker镜像创建redis5.0.3容器集群
拉取redis5.0.3镜像 # docker pull daocloud.io/library/redis:5.0.3 [root@localhost ~]# docker pull daoclou ...
- Docker镜像创建的三种方式详解——dockerfile制作apache镜像
基于已有的镜像容器进行创建 [root@localhost opt]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAM ...
- 三、docker镜像创建
(一)生产环境 [root@hp-uas01~]# dmidecode|grep "System Information" -A9|egrep "Manufacturer ...
- github上docker镜像创建容器
docker介绍 三个概念 1.镜像:类似于模版,在没有添加实例化前不能使用. 2.容器:镜像实例化. 3.docker:放容器的一个载体. 总结:docker就像一艘船,上面放的容器就是集装箱(co ...
- 直接用现成的docker镜像创建开发环境
在Docker Hub 上直接搜索搭建好的开发环境,然后把本地代码mount到docker, 不把时间浪费在搭建开发环境上. mount本地代码可参考建立基于docker的编译环境 - 云梦泽渔夫 - ...
- 创建支持nginx服务的docker镜像
环境: [root@linux-node1 ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@linux-n ...
- 通过Dockerfile创建docker镜像
创建镜像三种方法 Docker镜像创建方法有三种,分别为基于已有镜像创建.基于本地模板创建以及基于Dockerfile创建. 通过Dockerfile创建镜像 这里主要记录下基于Dockerfile创 ...
最新文章
- spring IOC创建对象方式
- 通过修改软链接升高 gcc 版本、降低 gcc 版本
- 架构师之路 — 数据库设计 — 关系型数据库的外键约束与关联
- 速度前瞻运动控制c语言程序_整合实时运动控制及多颗相机连接,大幅提升光学影像检测速度...
- 九度oj 题目1252:回文子串
- 初学__Python——Python 自定义函数
- I. Intersections
- 对一个 复杂的json结果进行取值的例子
- GitLab CI 中激活Anaconda环境
- python文本模糊匹配
- 计算机命令关闭445端口,关闭445端口命令是什么?设置关闭445端口的步骤教程
- android layout.inflater,LayoutInflater.inflate详解
- 爆笑!史上最强的中国式英语
- qsort C语言库函数实例使用演示
- Chapter 7 (Symmetric Matrices and Quadratic Forms): The Singular Value Decomposition (奇异值分解, SVD)
- HTML期末大作业—— 游戏网页(5个页面) ~ 全屏游戏美术大赛作品征集网页 HTML+CSS+JS ~ web课程设计网页规划与设计...
- 你了解净水器滤芯知识多少?
- 欧洲为何没有牛逼的互联网公司?
- Android 使用shape来画线
- PG12/GP7操作符+的实现[更正]