操作系统:
[root@yz6205 ~]# docker search busybox
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
busybox Busybox base image. 675 [OK]
progrium/busybox 61 [OK]
radial/busyboxplus Full-chain, Internet enabled, busybox made... 11 [OK]
odise/busybox-python 3 [OK]

[root@yz6205 ~]# docker pull busybox
latest: Pulling from busybox
56ed16bd6310: Pull complete
bc744c4ab376: Pull complete
Digest: sha256:4a887a2326ec9e0fa90cce7b4764b0e627b5d6afcb81a3f73c85dc29cea00048
Status: Downloaded newer image for busybox:latest

运行busybox
[root@yz6205 ~]# docker run -it busybox
/ # grep
BusyBox v1.24.2 (2016-03-18 16:38:06 UTC) multi-call binary.

Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...

Search for PATTERN in FILEs (or stdin)

查看mount挂载信息
/ # mount
rootfs on / type rootfs (rw)
/dev/sda5 on / type ext4 (rw,relatime,data=ordered)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev type tmpfs (rw,nosuid,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666)

修改Docker镜像的存储位置
http://blog.chinaunix.net/uid-20788636-id-4988546.html

创建容器:
[root@yz6205 ~]# docker run -ti ubuntu:14.04 /bin/bash
Unable to find image 'ubuntu:14.04' locally
Repository ubuntu already being pulled by another client. Waiting.
^C[root@yz6205 ~]# docker run -ti ubuntu /bin/bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from ubuntu
e9a1b385b0f6: Pull complete
92a77738f25d: Pull complete
e9f6d47ace10: Pull complete
b873f334fa52: Pull complete
7bd023c8937d: Pull complete
Digest: sha256:180f2869a492795d44a49bf4de244fde9f8d71db3c697c30600ef284ecb92bff
Status: Downloaded newer image for ubuntu:latest
root@6ab086fc9c3d:/#

配置软件源
root@6ab086fc9c3d:/# apt-get update
Get:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [94.5 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB

root@6ab086fc9c3d:/# apt-get install curl
root@6ab086fc9c3d:/# curl
curl: try 'curl --help' or 'curl --manual' for more information

root@6ab086fc9c3d:/# service apache2 start
* Starting Apache httpd web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.1. Set the 'ServerName' directive globally to suppress this message
*
root@6ab086fc9c3d:/# apt-get install apache2root@6ab086fc9c3d:/# curl 127.0.0.1:80

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

按照配置ssh
root@6ab086fc9c3d:/# apt-get install openssh-server
root@6ab086fc9c3d:/# mkdir -p /var/run/sshd
root@6ab086fc9c3d:/# /usr/sbin/sshd -D &
[1] 4806

root@6ab086fc9c3d:/# ps -ef |grep sshd
root 4806 1 0 13:59 ? 00:00:00 /usr/sbin/sshd -D

修改ssh服务的安全登陆配置,取消pam登陆限制
root@6ab086fc9c3d:/# sed -ri 's/session required pam_loginuid.so/#session required.so/g' /etc/pam.d/sshd
root@6ab086fc9c3d:/# mkdir root/.ssh
root@6ab086fc9c3d:/# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in y.
Your public key has been saved in y.pub.
The key fingerprint is:
SHA256:1OWc3jyk6bATo0fzU6Y0zsVgKFIXCvMchOTP3X9ZbI4 root@6ab086fc9c3d
The key's randomart image is:
+---[RSA 2048]----+
| .+o+ o.. |
| ..* = = . |
| o * o * . |
| = o + O . |
| S B B O +|
| o % B =o|
| . + B E.o|
| . . . . |
| |
+----[SHA256]-----+
root@6ab086fc9c3d:/# exit
exit

保存镜像

[root@yz6205 ~]# docker commit 6ab sshd:ubuntu
c82423c91c84b326afe47bbc475939e76637bfa42445318fe9b2afba01e0453d

[root@yz6205 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
sshd ubuntu c82423c91c84 47 seconds ago 332 MB
ubuntu latest 7bd023c8937d 5 days ago 122 MB

使用镜像
[root@yz6205 ~]# docker run -p 10022:22 -d sshd:ubuntu /run.sh
9ea4fd0fe1fc1636a622dcc4ae3457a3fcb7d0215441121e78172fad9e20dbc2

[root@yz6205 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9ea4fd0fe1fc sshd:ubuntu "/run.sh" About a minute ago Exited (0) 41 seconds ago tender_swartz

DOCKER实战案例的更多相关文章

  1. 3.awk数组详解及企业实战案例

    awk数组详解及企业实战案例 3.打印数组: [root@nfs-server test]# awk 'BEGIN{array[1]="zhurui";array[2]=" ...

  2. HTML+CSS小实战案例

    HTML+CSS小实战案例 登录界面的美化,综合最近所学进行练习 网页设计先布局,搭建好大框架,然后进行填充,完成页面布局 <html> <head> <meta htt ...

  3. python实战案例--银行系统

    stay hungry, stay foolish.求知若饥,虚心若愚. 今天和大家分享一个python的实战案例,很多人在学习过程中都希望通过一些案例来试一下,也给自己一点动力.那么下面介绍一下这次 ...

  4. php 网站301重定向设置代码实战案例

    php 网站301重定向设置代码实战案例 301重定向就是页面永久性移走的意思,搜索引擎知道这个页面是301重定向的话,就会把旧的地址替换成重定向之后的地址. 302重定向就是页面暂时性转移,搜索引擎 ...

  5. 【原创】Docker实战 Dockerfile最佳实践&&容器之间通信

    官方最佳实践文档 https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#from Docker实战(三十) ...

  6. 【Vue.js实战案例】- Vue.js递归组件实现组织架构树和选人功能

    大家好!先上图看看本次案例的整体效果. 浪奔,浪流,万里涛涛江水永不休.如果在jq时代来实这个功能简直有些噩梦了,但是自从前端思想发展到现在的以MVVM为主流的大背景下,来实现一个这样繁杂的功能简直不 ...

  7. 如何从40亿整数中找到不存在的一个 webservice Asp.Net Core 轻松学-10分钟使用EFCore连接MSSQL数据库 WPF实战案例-打印 RabbitMQ与.net core(五) topic类型 与 headers类型 的Exchange

    如何从40亿整数中找到不存在的一个 前言 给定一个最多包含40亿个随机排列的32位的顺序整数的顺序文件,找出一个不在文件中的32位整数.(在文件中至少确实一个这样的数-为什么?).在具有足够内存的情况 ...

  8. 阿里云云主机swap功能设置实战案例

    阿里云云主机swap功能设置实战案例 阿里云提供的云服务器(Elastic Compute Service,简称 ECS),是云主机的一种,当前采用的虚拟化驱动是Xen(这一点可以通过bios ven ...

  9. 分布式事务之——tcc-transaction分布式TCC型事务框架搭建与实战案例(基于Dubbo/Dubbox)

    转载请注明出处:http://blog.csdn.net/l1028386804/article/details/73731363 一.背景 有一定分布式开发经验的朋友都知道,产品/项目/系统最初为了 ...

随机推荐

  1. Ionic的下拉框在手机上点击无效

    最近在维护ionic+angular的项目,在浏览器使用下拉框的时候调试的时候,一切正常. 但是在手机上测试的时候,遇到这个问题. 我使用的版本是ionic1.3.1,不知道新版本有没有解决这个bug ...

  2. 流畅的python 14章可迭代的对象、迭代器 和生成器

    可迭代的对象.迭代器和生成器 迭代是数据处理的基石.扫描内存中放不下的数据集时,我们要找到一种惰性获取数据项的方式,即按需一次获取一个数据项.这就是迭代器模式(Iterator pattern). 迭 ...

  3. sql查询原理和Select执行顺序

    一 sql语句的执行步骤 1)语法分析,分析语句的语法是否符合规范,衡量语句中各表达式的意义. 2) 语义分析,检查语句中涉及的所有数据库对象是否存在,且用户有相应的权限. 3)视图转换,将涉及视图的 ...

  4. blogCMS中出现的错误整理

    1.在写日期归档的时候,出现如下错误: not enough values to unpack (expected 2, got 1) 出现这个错误是因为:字符串需要能够split成2份才能赋值给2个 ...

  5. Java面向对象—多态

    概述:同一个事物,在不同的时刻表现出不同的状态. 代码中如何体现: 要有继承, 要有方法重写, 父类引用指向子类对象 多态的成员访问特点 成员变量:编译看左边(父类), 运行看左边 成员方法:编译看左 ...

  6. 三道半平面交测模板题 Poj1474 Poj 3335 Poj 3130

    求半平面交的算法是zzy大神的排序增量法. ///Poj 1474 #include <cmath> #include <algorithm> #include <cst ...

  7. Javascript中call()和apply()的用法 ----1

    1.方法定义 call方法: 语法:call([thisObj[,arg1[, arg2[,   [,.argN]]]]]) 定义:调用一个对象的一个方法,以另一个对象替换当前对象. 说明: call ...

  8. dojo 官方翻译 dojo/Deferred

    延迟,异步调用 官网地址:http://dojotoolkit.org/reference-guide/1.9/dojo/Deferred.html require(["dojo/Defer ...

  9. 使用Linq to XML 修改app.config

    使用其他的方法修改app.config无效.而且修改的是*.vshost.exe.Config,程序运行时正常,关闭之后就还是原来的值. Configuration configuration = C ...

  10. List To Json

    命名空间 using Newtonsoft.Json; 实例代码 /// <summary> /// 将list集合转换为json /// </summary> /// < ...