DOCKER实战案例
操作系统:
[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实战案例的更多相关文章
- 3.awk数组详解及企业实战案例
awk数组详解及企业实战案例 3.打印数组: [root@nfs-server test]# awk 'BEGIN{array[1]="zhurui";array[2]=" ...
- HTML+CSS小实战案例
HTML+CSS小实战案例 登录界面的美化,综合最近所学进行练习 网页设计先布局,搭建好大框架,然后进行填充,完成页面布局 <html> <head> <meta htt ...
- python实战案例--银行系统
stay hungry, stay foolish.求知若饥,虚心若愚. 今天和大家分享一个python的实战案例,很多人在学习过程中都希望通过一些案例来试一下,也给自己一点动力.那么下面介绍一下这次 ...
- php 网站301重定向设置代码实战案例
php 网站301重定向设置代码实战案例 301重定向就是页面永久性移走的意思,搜索引擎知道这个页面是301重定向的话,就会把旧的地址替换成重定向之后的地址. 302重定向就是页面暂时性转移,搜索引擎 ...
- 【原创】Docker实战 Dockerfile最佳实践&&容器之间通信
官方最佳实践文档 https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#from Docker实战(三十) ...
- 【Vue.js实战案例】- Vue.js递归组件实现组织架构树和选人功能
大家好!先上图看看本次案例的整体效果. 浪奔,浪流,万里涛涛江水永不休.如果在jq时代来实这个功能简直有些噩梦了,但是自从前端思想发展到现在的以MVVM为主流的大背景下,来实现一个这样繁杂的功能简直不 ...
- 如何从40亿整数中找到不存在的一个 webservice Asp.Net Core 轻松学-10分钟使用EFCore连接MSSQL数据库 WPF实战案例-打印 RabbitMQ与.net core(五) topic类型 与 headers类型 的Exchange
如何从40亿整数中找到不存在的一个 前言 给定一个最多包含40亿个随机排列的32位的顺序整数的顺序文件,找出一个不在文件中的32位整数.(在文件中至少确实一个这样的数-为什么?).在具有足够内存的情况 ...
- 阿里云云主机swap功能设置实战案例
阿里云云主机swap功能设置实战案例 阿里云提供的云服务器(Elastic Compute Service,简称 ECS),是云主机的一种,当前采用的虚拟化驱动是Xen(这一点可以通过bios ven ...
- 分布式事务之——tcc-transaction分布式TCC型事务框架搭建与实战案例(基于Dubbo/Dubbox)
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/73731363 一.背景 有一定分布式开发经验的朋友都知道,产品/项目/系统最初为了 ...
随机推荐
- threading模块、ThreadLocal
一.threading模块 1.线程对象的创建 1.1 Thread类直接创建 import threading import time def countNum(n): # 定义某个线程要运行的函数 ...
- LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: --异常记录
升级了JDK之后,启动应用,直接抛出此异常.网上搜罗半天,没有正确的解决方案. 然后想到了是“升级了JDK”,重新检查所有JDK相关的配置的地方,在Debug Configurations里找到启动时 ...
- CNN学习笔记:激活函数
CNN学习笔记:激活函数 激活函数 激活函数又称非线性映射,顾名思义,激活函数的引入是为了增加整个网络的表达能力(即非线性).若干线性操作层的堆叠仍然只能起到线性映射的作用,无法形成复杂的函数.常用的 ...
- HDU - 6311 Cover (欧拉路径)
题意:有最少用多少条边不重复的路径可以覆盖一个张无向图. 分析:对于一个连通块(单个点除外),如果奇度数点个数为 k,那么至少需要max{k/2,1} 条路径.将奇度数的点两两相连边(虚边),然后先 ...
- windo form 窗体布局方式
DataGridView:显示数据表后台数据绑定:List<xxx> list = new List<xxx>();dataGridView1.DataSource = lis ...
- display:inline-block; 去除间隙的方法 总结:
个人常用: 如: <ul> <li><a href="#" >实时数据</a></li> <li><a ...
- onerror事件
onerror 事件会在文档或图像加载过程中发生错误时被触发. 案例: <img onerror="this.onerror=null;this.src='/images/common ...
- ReadyBoost
ReadyBoost是Windows Vista中的新技术,在继Windows Vista的下一代操作系统Windows 7中,同样包含了这项技术,它利用了闪存随机读写及零碎文档读写上的优势来提高计算 ...
- CSS3小图标菜单导航
在线演示 本地下载
- MySQL性能优化之max_connections参数
很多开发人员都会遇见”MySQL: ERROR 1040: Too many connections”的异常情况,造成这种情况的一种原因是访问量过高,MySQL服务器抗不住,这个时候就要考虑增加从服务 ...