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信息描述 ...
随机推荐
- D. Pair Of Lines( Educational Codeforces Round 41 (Rated for Div. 2))
#include <vector> #include <iostream> #include <algorithm> using namespace std; ty ...
- ie img 3px bug
ie img 3px bug 日期:2008-11-22 分类:CSS ie img 有 3px 的缝隙也是 ie 的经典 bug 之一,相信已经不陌生了,但还是先看看效果吧(也许你并没有见过): 效 ...
- 最近工作用到压缩,写一个zip压缩工具类
package test; import java.io.BufferedOutputStream;import java.io.File;import java.io.FileInputStream ...
- GYM 101889J(枚举、环上gcd)
答案只有n - 1种暴举即可,对于每种,gcd是一那踩雷稳了,否则看雷的分布有没有把模余占满. const int maxn = 1e5 + 5; int n, ans; char str[maxn] ...
- css未知宽度水平居中整理
1.text-align 兼容性很好 .wp {text-align: center;} .test {display: inline;} <ul class="wp"> ...
- html5拖动滑块
html5中input有增加type=range.这为拖动滑块提供了很大的便利.下面是他的属性: <!DOCTYPE html> <html lang="en"& ...
- vue.js 2.0 学习笔记
指令带有前缀 v-,表示是由 Vue 提供的专用属性. v-on 指令 来增加事件监听器,触发事件后会调用 Vue 实例中 methods 下定义的方法 v-model 指令,使得表单输入和应用程序状 ...
- hihocoder1080 更为复杂的买卖房屋姿势
思路: 线段树区间修改,需要使用两个懒标记set和add.处理好两个标记的优先级即可(set之前的set和add是没有作用的). 实现: #include <bits/stdc++.h> ...
- JQ中的问题
$(function(){$(document).bind("click", function (e) {$(e.target).closest("p").cs ...
- Obj-C Memory Management
Memory management is one of the most important process in any programming language. It is the proces ...