docker--build base image
通过dockerfile build一个base image,在上面运行一个c程序
首先
1、创建一个目录。
2、然后创建一个c写的小程序,并且gcc编译好。
3、创建一个Dockerfile
FROM scratch #scrath表示运行在内核之上
ADD soeasy2 / #增加文件
CMD ["/soeasy2"]#运行程序
4、build image
5、运行image
[root@localhost docker_test]# ls
Dockerfile soeasy2 soeasy.c soeasy.sh
[root@localhost docker_test]# vim Dockerfile
[root@localhost docker_test]# docker build -t bigni/test1 . #-t表示tag 最后的点号,表示在当前目录寻找Dockerfile
Sending build context to Docker daemon .8kB
Step / : FROM scratch
--->
Step / : ADD soeasy2 /
---> 3ec8199c2855
Step / : CMD ["/soeasy2"]
---> Running in 7fcaf3239425
Removing intermediate container 7fcaf3239425
---> f5620b92331c
Successfully built f5620b92331c
Successfully tagged bigni/test1:latest
[root@localhost docker_test]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
bigni/test1 latest f5620b92331c seconds ago 861kB
ubuntu 14.04 2c5e00d77a67 weeks ago 188MB
centos latest 9f38484d220f months ago 202MB
hello-world latest fce289e99eb9 months ago .84kB
[root@localhost docker_test]# docker run f5620b92331c #运行image
docker so easy
[root@localhost docker_test]# cat Dockerfile
FROM scratch
ADD soeasy2 /
CMD ["/soeasy2"]
[root@localhost docker_test]# cat soeasy.c
#include<stdio.h> int main()
{
printf("docker so easy\n");
}
[root@localhost docker_test]#
把程序改成shell脚本,然后还是在linux kernel上构建base image,结果程序运行不起来,改成在centos image上构建,则运行成功。
[root@localhost docker_test]# vim soeasy.sh
[root@localhost docker_test]# cat soeasy.sh
#!/bin/bash
echo "docker so easy !"
[root@localhost docker_test]# vim Dockerfile
[root@localhost docker_test]# cat Dockerfile
FROM scratch
ADD soeasy.sh /
CMD ["/soeasy.sh"]
[root@localhost docker_test]# docker build -t bigni/test2 .
Sending build context to Docker daemon .8kB
Step / : FROM scratch
--->
Step / : ADD soeasy.sh /
---> 93d27c3e1b5b
Step / : CMD ["/soeasy.sh"]
---> Running in 4af6bd362099
Removing intermediate container 4af6bd362099
---> e2b5b08cc31c
Successfully built e2b5b08cc31c
Successfully tagged bigni/test2:latest
[root@localhost docker_test]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
bigni/test2 latest e2b5b08cc31c About a minute ago 36B
bigni/test1 latest f5620b92331c minutes ago 861kB
ubuntu 14.04 2c5e00d77a67 weeks ago 188MB
centos latest 9f38484d220f months ago 202MB
hello-world latest fce289e99eb9 months ago .84kB
[root@localhost docker_test]# docker run e2b5b08cc31c #运行image
standard_init_linux.go:: exec user process caused "no such file or directory"
[root@localhost docker_test]# vim Dockerfile
[root@localhost docker_test]# cat Dockerfile
FROM centos #改成centos
ADD soeasy.sh /
CMD ["/soeasy.sh"]
[root@localhost docker_test]# docker build -t bigni/test3 .
Sending build context to Docker daemon .8kB
Step / : FROM centos
---> 9f38484d220f
Step / : ADD soeasy.sh /
---> 9ae6ad56171a
Step / : CMD ["/soeasy.sh"]
---> Running in b53205a3eb75
Removing intermediate container b53205a3eb75
---> cfbfd0a29d1c
Successfully built cfbfd0a29d1c
Successfully tagged bigni/test3:latest
[root@localhost docker_test]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
bigni/test3 latest cfbfd0a29d1c seconds ago 202MB
bigni/test2 latest e2b5b08cc31c minutes ago 36B
bigni/test1 latest f5620b92331c minutes ago 861kB
ubuntu 14.04 2c5e00d77a67 weeks ago 188MB
centos latest 9f38484d220f months ago 202MB
hello-world latest fce289e99eb9 months ago .84kB
[root@localhost docker_test]# docker run cfbfd0a29d1c
docker so easy !
[root@localhost docker_test]#
docker--build base image的更多相关文章
- Docker build Dockerfile 构建镜像 - 二
Dockerfile 制作镜像 https://hub.docker.com/ 搜索需要镜像: https://hub.docker.com/_/centos/ 官方示例: centos:6 1.这里 ...
- [Docker] Build a Simple Node.js Web Server with Docker
Learn how to build a simple Node.js web server with Docker. In this lesson, we'll create a Dockerfil ...
- 【云计算】docker build如何支持参数化构建?
docker 1.9.0版本之后,已经支持docker build参数化构建. docker 版本更新记录: github讨论: 参开资料: https://github.com/docker/doc ...
- docker: "build" requires 1 argument. See 'docker build --help'.
http://bbs.csdn.net/topics/391040030 docker build --tag="ouruser/sinatra:v3" -<Dockerf ...
- Jenkins Docker安装及Docker build step插件部署配置
生产部署环境:A:192.168.1.2 B:192.168.1.3 两台服务器系统均是Centos 7.3 , Docker版本都1.12.6 Jenkins安装操作步骤: 1.在A服务器上使用命 ...
- 25.week4 docker build 也就是创建自己的image 上传image到dockerhub 从dockerhub下载images
dado可以写你自己的名字 这个命令就会根据目录下的Dockerfile(固定用和这个名字)文件里面的内容 去下载并创建运行命令一步一步地 Setting up libxfixes3:amd64 (: ...
- docker build 指定dockerfile
1. Dockerfile文件使用 docker build命令会根据Dockerfile文件及上下文构建新Docker镜像.构建上下文是指Dockerfile所在的本地路径或一个URL(Git仓库地 ...
- "docker build" requires exactly 1 argument(s).
Docker 是怎么样的东西,这里就不说了,这里说说dockerfile创建容器时遇到的问题. 首先我想达到的目的很简单,就是用dockerfile去创建容器,步骤如下: 创建并编辑dockerfil ...
- 使用dockerfile文件创建镜像时docker build没有反应
问题: 先 docker pull centos:7 拉取了一个官方的基础镜像,为后续创建jdk8镜像做准备,在创建如下的dockerfile文件 执行docker build -t jdk_8u19 ...
- gradle multiproject && docker build
备注: 环境准备 : docker , gradle(使用wrapper,或者全局安装),测试环境使用mac 1. gradle 安装 brew install gradle 2. docke ...
随机推荐
- 两种图片延迟加载的方法总结jquery.scrollLoading.js与jquery.lazyload.js---转载
jquery.scrollLoading方法 html <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml& ...
- jQuery仿Android锁屏图案应用插件
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- mac 支持rz sz
安装 lrzsz brew install lrzsz 配置 iTerm2 安装完成后我们需要在 iTerm2 中使用的话,还需要一些配置 进入到 /usr/local/bin 目录下,下载两个脚本文 ...
- WPF 的二维绘图(二)——几何图形Geometry
<本文转自同行> 在WPF的DrawingContext对象中,提供了基本的绘制椭圆和矩形的API:DrawEllipse和DrawRectangle.但是,这些是远远不够用的,我们在日常 ...
- Tkinter初体验
一.基本步骤 1.导入Tkinter模块 2.创建根窗口 3.填充组件 4.组件关联逻辑 5.进入主循环 二.Code #coding:utf-8 ''' 网关流量校验器 @author: Hongz ...
- 绘图matplotlib
前言 matplotlib是python的一个绘图库,如果你没有绘制过图,可以先试试js的绘图库http://www.runoob.com/highcharts/highcharts-line-lab ...
- windows下基于(QPC)实现的微秒级延时
1.为什么会写windows下微秒级延时 在上一篇 实现memcpy()函数及过程总结 中测试memcpy的效率中,测试时间的拷贝效率在微秒级别,需要使用微秒级时间间隔计数. windows下提供Qu ...
- json书写格式
1.数组方式 [ ] [{ "id" : 1 , "name" : "xiaoming" },{ "id" : 2 , ...
- CF963E Circles of Waiting
Circles of Waiting 求一个整点四连通随机游⾛,离原点距离超过R期望步数.R≤50. 带状矩阵法 本质上就是网格图的随机游走. \[ E_x=\sum_y P_{x,y}E_y+1 \ ...
- OpenCV常用基本处理函数(1)读写
图像的基本操作 cv.imread() 读取图片 cv.imshow() 显示图片 cv2.imwrite() 保存图像 使用摄像头捕获实时图像 OpenCV 为这中应用提供了 ...