操作系统:
[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. Shell下syntax error: operand expected (error token is “-”)

    在这个监控实时网口速率的脚本中,第21,22行存在错误: #!/bin/bash #Modified by lifei4@datangmobile.cn echo ===DTmobile NetSpe ...

  2. 一.数据库连接对象connection

    1.python 3.5,需要把MySQLdb换成pymysql

  3. django一些配置与ORM

  4. 用python合并N个不同字符集编码的sql文件的实践

    背景:我有一项工作任务是将svn某文件夹日常更新的sql文件(归类到日期命名的文件夹中)拿到数据库中运行. 一開始,我是先把sql文件update下来,用notepad++打开,拷贝每个文本的sql语 ...

  5. python16_day11【MQ、Redis、Memcache】

    一.RabbitMQ 是一个在AMQP基础上完整的,可复用的企业消息系统.他遵循Mozilla Public License开源协议. MQ全称为Message Queue, 消息队列(MQ)是一种应 ...

  6. nginx限制连接

    limit_conn_zone $binary_remote_addr zone=addr:10m; locaton /download { limit_rate_after 128k; #是对每个连 ...

  7. Linux x86架构下ACPI PNP Hardware ID的识别机制

    转:https://blog.csdn.net/morixinguan/article/details/79343578 关于Hardware ID的用途,在前面已经大致的解释了它的用途,以及它和AC ...

  8. linux新手学习之Arch Linux入门经验分享

    我一直是以Ubuntu与Fedora作为新手入门的系统,但是其实我真正想推荐的是Arch,经过前面的学习,或许你对Linux已经有了一个大致的了解,现在如果你想加速你的步伐,也许可以看看本文.如果要问 ...

  9. web页面如何打包封闭成手机APP

    所谓的webApp就是html页面跟原生app结合而成的一种应用,这种应用的开发可以节省不少的成本,做出来的app跟原生一样,webApp利用框架技术可以让你有使用app的感觉,具体可以看平安银行的a ...

  10. Effective C++ 条款05:了解C++编写并调用哪些函数

    规则一 编译器默认操作 // 你认为 class Empty { }; // 实际上 class Empty { public: Empty() { ... } // default 构造函数 Emp ...