操作系统:
[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

最新文章

  1. SQL Server 2008 R2——查找最小nIndex,nIndex存在而nIndex+1不存在 求最小连续数组中的最大值
  2. 从jquery里的$.ajax()到angularjs的$http
  3. SSM框架学习之高并发秒杀业务--笔记5-- 并发优化
  4. logresolve - 解析Apache日志中的IP地址为主机名
  5. 《ASP.NET MVC 5 高级编程(第5版)》
  6. 数据库留言板例题:session和cookie区别
  7. iOS 自定义UITabBarController的tabBar
  8. 【转】JVM 分代GC策略分析
  9. C#如何获得本地电脑IP
  10. implements KeyListener但关键监听器监听少
  11. 零基础入门学习javase,应该怎么学?这是我给你的一个建议
  12. Netty、t-io、Voovan 框架比较
  13. 关于Jpa和Mybatis的一些看法
  14. SQLyog 最新版本12.5-64bit 完美破解,亲测可用!
  15. Linux 的文件软链接如何删除
  16. 关于wincc与博图的安装问题
  17. MVVM 和 VUE
  18. 121. Best Time to Buy and Sell Stock 买卖股票的最佳时机
  19. spring boot 入门 使用spring.profiles.active来分区配置
  20. A1020. Tree Traversals(25)

热门文章

  1. git 解决push报错:[rejected] master -&gt; master (fetch first) error: failed to push some refs to
  2. django-应用中和amdin使用富文本编辑器kindeditor
  3. Django的model模型
  4. DRF(4) - 认证、权限组件
  5. Dom4j总结
  6. node.js---sails项目开发(3)
  7. Android用surface直接显示yuv数据(三)
  8. JS连等赋值的坑
  9. 按钮js跳转到非表单提交页
  10. Java集合(9):ConcurrentHashMap