docker系列之基础命令-2
一.查看本地镜像
docker images
二.需要基础的镜像两种方式
1.docker pull centos 可以直接拉起镜像
2.直接用xshell导入就行,docker load -i 加镜像名 先把之前下载下来的镜像导入到服务器上然后拉起镜像
三.查看服务器上有那些功能的centos镜像
docker search centos

四,构建自己的镜像
docker images
docker run -it 加镜像名 /bin/bash 根据centos镜像起容器, t参数:打开猥终端,-i参数:与这个终端保持交互模式
yum -y install apr apr-util httpd 安装apache
yum clean all 清缓存
五.退出容器
exit, ctrl +d,ctrl + c容器直接关闭,ctrl+p然后ctrl+q退出还是运行状态的
六。查看容器状态
docker ps -a 看下容器状态
docker ps -l 查看最新拉起来的容器
七。容器做成镜像,通过镜像运行容器(相当于起了个服务)
docker commit -m ‘commit-httpd’ -a 'yft' 容器id 启一个名字 -m参数:描述信息,-a参数:后加维护者的信息
docker commit -m ‘commit-httpd’ -a ‘yft’ 容器id centos:commit-httpd 会返回镜像id
docker images 查看镜像的id(前12位的)
docker run -it centos:commit-httpd /bin/bash 运行起镜像就是启动了apache服务
apachectl -k start 启动apache
echo 'test' > /var/www/html/index.html 做一个测试页
curl http://127.0.0.1/index.html
docker inspect -f '{.NetworkSettings.IPAddress.}' +容器名或id docker inspect查看到容器的很详细的信息,加上后面就是看到ip的具体信息(过滤出我们需要的信息)
八。dockerfile构建镜像
mkdir -p /docker/httpd(创建个目录)
cd /docker/httpd
vim Dockerfile
#dockerfile build httpd images 基于哪个镜像构建
FROM 镜像的名字
MAINTAINER yft
RUN yum -y install apr apr-util httpd
RUN yum clean all
docker built -t 'centos:dockerfile-httpd' . "."这个点指的是dockerfile所在的路径(当前路径),也可以替换为一个具体的dockerfile的绝对路径
docker images查看是否生成镜像了
docker run -it 镜像名 /bin/bash 启动这个容器(容器就相当于开机,容器里面就是服务)
apachectl -k start (进入容器启动服务)
ps -ef 查看服务是否启动
九。如何上传镜像(上传到官方仓库)
docker tag centos:dockerfile-httpd leixilongge/baoge (先打标签)
docker push
十。存入和导出镜像
docker save -o centos-dockerfile.tar centos:dockerfile=httpd导出这个镜像的tar包
scp root@192.168.1.1:/root/centos-dockerfile.tar ./从另一台服务器上执行这条命令,把这个tar包考到当前服务器上
docker系列之基础命令-2的更多相关文章
- docker系列之基础命令-1
1.docker基础命令 docker images 显示镜像列表 docker ps 显示容器列表 docker run IMAGE_ID 指定镜像, 运行一个容器 docker start/sto ...
- Docker系列之常用命令操作手册
目录 1.安装虚拟机 2.安装Docker 3.Docker镜像操作 4.Docker容器操作 Docker系列之常用命令操作手册 继上一篇博客Docker系列之原理简单介绍之后,本博客对常用的Doc ...
- docker学习(2)--基础命令
转载请注明源出处:http://www.cnblogs.com/lighten/p/6875355.html 1.基本命令 搭建好docker环境之后,使用docker help命令查看docker的 ...
- Docker容器技术-基础命令
一.基础命令 1.运行一个镜像 [root@bogon ~]# docker run debian echo "Hello World" Unable to find image ...
- Docker虚拟化之<基础命令>
1.在docker hub中搜索镜像 docker search nginx 2.从docker镜像服务器拉取指定镜像或者库镜像 docker pull docker.io/nginx 3.列出系统当 ...
- Docker安装及基础命令
一.docker安装 1.安装docker #关闭防火墙和selinux systemctl stop firewalld.service setenforce 0 #安装依赖包 yum ins ...
- Docker 系列之 基础入门
安装 Docker Windows 10 专业版以上版本 Docker for Windows Installer 在安装前,需要确保目标机器已经开启了硬件虚拟化和 HyperV :在安装的过程中建议 ...
- Docker系列(三)常用命令
命令说明 docker pull 格式: docke pull [OPTIONS] NAME[:TAG] 作用:下载名称为 name 的镜像 例子: sudo docker pull dl.docke ...
- Docker系列之基础实践篇(上)
常用命令回顾 帮助命令 1.启动docker //启动 $ systemctl start docker 2.查看docker版本 $ docker version 3.查看安装的docker信息描述 ...
随机推荐
- python元组,列表,字典练习
#coding = utf-8 goods_data = (["iphone7",8000],["mac pro",12000],["bike&quo ...
- Zynq7000开发系列-7(在Zybo上运行Linaro桌面系统)
目标板:Zybo(7Z010) 主机操作系统:Ubuntu 14.04.5 LTS 64bit 交叉编译链: arm-xilinx-linux-gnueabi- [gcc version ...
- 洛谷 P4362 [NOI2002]贪吃的九头龙
https://www.luogu.org/problemnew/show/P4362 首先有个很显然的dp:ans[i][j][k]表示i节点用j号头,i节点为根的子树中共有k个点用大头时i节点为根 ...
- thinkphp分页集成
控制器: $User = M('webcase'); // 实例化 User 对象 $list = $User->order('id desc')->page($_GET['p'].', ...
- Yii2中多表关联查询(with、join、joinwith)
表结构 现在有客户表.订单表.图书表.作者表, 客户表Customer (id customer_name) 订单表Order (id order_name custome ...
- Tunneling cannot be enabled without the local_ip bound to an interface on the host. Please configure local_ip 192.168.30.71 on the host interface to be used for tunneling and restart the agen
按照官方文档配置linux bridge 会出现一下问题 Tunneling cannot be enabled without the local_ip bound to an interface ...
- 2012-2013 ACM-ICPC, NEERC, Central Subregional Contest C Sequence (打表)
打个表找找规律,到24445的时候乘2以后产生了0出现循环. 一般地,判断循环节是否存在可以用Floyd判圈算法. #include<bits/stdc++.h> using namesp ...
- UVA Live 3713 Astronauts (2-SAT)
用布尔变量表示状态,把限制条件转化为XνY的形式以后跑2SAT,根据变量取值输出方案. #include<bits/stdc++.h> using namespace std; ; #de ...
- 在web应用中使用日志
Log4J是Jakarta下的一个开源代码的子项目,用Log4J,我们可以使用定制的格式,把调试信息和日志信息输出到一个或多个需要的地方. 在Web应用中一般使用一个专门的Servlet来完成Log4 ...
- C++类构造函数、析构函数运行机理
http://blog.sina.com.cn/s/blog_6fd68d5f0100n60h.html 前言--构造函数.析构函数的简单理解:1)构造函数---对象被创建时候调用的函数:2)析构函数 ...