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 ...
随机推荐
- 为什么tcp-wrappers被Redhat Centos Fedora废弃?
1 简述 TCP wrappers is a simple tool to block incoming connection on application level. This was very ...
- Workbox使用策略
1.什么是Workbox Strategies? 当service workers 首次被引入时,可以设定一组常见的缓存策略. 缓存策略是一种模式,用于确定service workers 在收到fet ...
- bzoj2582 [Usaco2012Jan]Bovine Alliance
[Usaco2012Jan]Bovine Alliance Time Limit: 2 Sec Memory Limit: 128 MB Description Bessie and her bovi ...
- netbean out of memory java heap space
When run test file in netbean. all dependency and resource are right, but it raise up java.lang.OutO ...
- linux mysql数据库安装
1.创建mysql用户账号:groupadd mysqluseradd -d /sbin/nolog -g mysql -M mysql-s /sbin/nologin 表示禁止该用户登录,只需要角色 ...
- Vue小白篇 - Vue 的指令系统 (1) v-text、v-html
v-text:相当于innerText v-html:相当于innerHTML <div id="box"> {{ msg }} <div v-text=&quo ...
- 2019-11-7-WPF-How-to-get-plain-text-from-RichTextBox
title author date CreateTime categories WPF How to get plain text from RichTextBox lindexi 2019-11-0 ...
- Tkinter初体验
一.基本步骤 1.导入Tkinter模块 2.创建根窗口 3.填充组件 4.组件关联逻辑 5.进入主循环 二.Code #coding:utf-8 ''' 网关流量校验器 @author: Hongz ...
- (PASS)JAVA数组去重 三种方法 (不用集合)
第一种方法(只学到数组的看): 定义一个新的数组长度和旧数组的长度一样,存储除去重复数据的旧数组的数据和0, package demo01; import java.sql.Array; import ...
- bootsrap 按钮样式
<!-- Standard button --> <button type="button" class="btn btn-default"& ...