docker之container
转自:https://www.cnblogs.com/jsonhc/p/7760144.html
[root@docker ~]# docker run -t -a stdin centos sh -c "while true;do echo hello world;sleep 2;done"
b7930a6c5c4cdf2b73e24e26f2a8fd801e9eb11a1e28b0a376d180d3fd2e4d4a
[root@docker ~]# docker logs b7930a6c5c4c
hello world
hello world
# docker run -dt --name mycentos centos sh -c "while true;do echo hello world;sleep 2;done"
[root@docker ~]# ifconfig
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
inet6 fe80::42:efff:fe2d:d653 prefixlen 64 scopeid 0x20<link>
ether 02:42:ef:2d:d6:53 txqueuelen 0 (Ethernet)
RX packets 1 bytes 76 (76.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3 bytes 258 (258.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.101.14 netmask 255.255.255.0 broadcast 192.168.101.255
inet6 fe80::9b70:a5ba:c2d6:d665 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:07:65:c0 txqueuelen 1000 (Ethernet)
RX packets 375314 bytes 497786475 (474.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 134729 bytes 10091671 (9.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 280 bytes 22624 (22.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 280 bytes 22624 (22.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 veth9bd4211: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::5045:f6ff:fef6:da10 prefixlen 64 scopeid 0x20<link>
ether 52:45:f6:f6:da:10 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 648 (648.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vethe1ab8ab: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::e0e5:e5ff:fe58:ddec prefixlen 64 scopeid 0x20<link>
ether e2:e5:e5:58:dd:ec txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 648 (648.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b7930a6c5c4c centos "sh -c 'while true..." 5 minutes ago Up 5 minutes stoic_shirley
8179b8e95e31 centos "sh -c 'while true..." 15 minutes ago Up 15 minutes mycentos
# docker run -t --net host saltstack/ubuntu-14.04 sh -c "while true;do ifconfig;sleep 2;done"
[root@docker ~]# docker run -d --net host saltstack/ubuntu-14.04 python -m SimpleHTTPServer
cd07720586501b298c90067e33fb3c099e6e14d91b9de4327026cc2f06321e08
[root@docker ~]# docker run -dt -p 8000 saltstack/ubuntu-14.04 python -m SimpleHTTPServer
f7d04a31f5a2d6220a70c8dd7d78a5819bd722b3baab9e743c6c098533bd96ec
[root@docker ~]# docker run -dt -p 80:8000 saltstack/ubuntu-14.04 python -m SimpleHTTPServer
a9c3d1c7b6f4319ee34fe726eb5989b7f20bdf4e75e26ef4d5e734665c7efa75
python -m SimpleHTTPServer:这个服务开启的默认端口为8000
如果想映射多个端口时:
[root@docker ~]# mkdir test/wadeson -p
[root@docker ~]# docker run -t -v /root/test:/wadeson saltstack/ubuntu-14.04 sh -c "ls -al /wadeson"
total 0
drwxr-xr-x. 3 root root 21 Oct 27 22:09 .
drwxr-xr-x. 22 root root 257 Oct 27 22:10 ..
drwxr-xr-x. 2 root root 6 Oct 27 22:09 wadeson
[root@docker ~]# docker run -it -v /data -h wadeson saltstack/ubuntu-14.04
root@wadeson:/# ls
bin boot data dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@wadeson:/# ls /data/
root@wadeson:/#
"Mounts": [
{
"Type": "volume",
"Name": "71025e4f8325fce175e21861a1fe0d089b9a08760778a8c9c517d6391c0dbceb",
"Source": "/var/lib/docker/volumes/71025e4f8325fce175e21861a1fe0d089b9a08760778a8c9c517d6391c0dbceb/_data",
"Destination": "/data",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
[root@docker _data]# pwd
/var/lib/docker/volumes/71025e4f8325fce175e21861a1fe0d089b9a08760778a8c9c517d6391c0dbceb/_data
[root@docker _data]# ll
total 0
[root@docker _data]# touch wadeson.sh
[root@docker _data]# ll
total 0
-rw-r--r--. 1 root root 0 Oct 26 21:46 wadeson.sh
root@wadeson:/# ls /data/
wadeson.sh
[root@docker ~]# docker run -it -v /root:/root -h wadeson saltstack/ubuntu-14.04
root@wadeson:/# ls /root/
anaconda-ks.cfg docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm
[root@docker volumes]# ll
total 24
drwxr-xr-x. 3 root root 19 Oct 26 21:46 71025e4f8325fce175e21861a1fe0d089b9a08760778a8c9c517d6391c0dbceb
-rw-------. 1 root root 32768 Oct 26 21:39 metadata.db
docker run -it -v /root:/root:ro -h wadeson saltstack/ubuntu-14.04
[root@docker ~]# docker run -it --volumes-from b8c05a805280 -h wadeson saltstack/ubuntu-14.04
root@wadeson:/# ls /data/
root@wadeson:/#
[root@docker volumes]# ll
total 24
drwxr-xr-x. 3 root root 19 Oct 26 21:46 71025e4f8325fce175e21861a1fe0d089b9a08760778a8c9c517d6391c0dbceb
drwxr-xr-x. 3 root root 19 Oct 26 22:11 f808fc539538ba743c08a852b4b8c4e52c61a33df4c8e52032596385a39b963b
-rw-------. 1 root root 32768 Oct 26 22:11 metadata.db
[root@docker volumes]# cd f808fc539538ba743c08a852b4b8c4e52c61a33df4c8e52032596385a39b963b/_data/
[root@docker _data]# ll
total 0
[root@docker ~]# docker run --name redis -dt redis
7014723aea605fa4baedb83be8e5f6d528b2fc009aa4379a1694f3131b72b041
[root@docker ~]# docker run --link redis:db -t saltstack/ubuntu-14.04 sh -c "export"
export DB_ENV_GOSU_VERSION='1.10'
export DB_ENV_REDIS_DOWNLOAD_SHA='b1a0915dbc91b979d06df1977fe594c3fa9b189f1f3d38743a2948c9f7634813'
export DB_ENV_REDIS_DOWNLOAD_URL='http://download.redis.io/releases/redis-4.0.2.tar.gz'
export DB_ENV_REDIS_VERSION='4.0.2'
export DB_NAME='/wizardly_keller/db'
export DB_PORT='tcp://172.17.0.2:6379'
export DB_PORT_6379_TCP='tcp://172.17.0.2:6379'
export DB_PORT_6379_TCP_ADDR='172.17.0.2'
export DB_PORT_6379_TCP_PORT='6379'
export DB_PORT_6379_TCP_PROTO='tcp'
export HOME='/root'
export HOSTNAME='192208a0c626'
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
export PWD='/'
export TERM='xterm'
docker之container的更多相关文章
- 如何获取 docker 容器(container)的 ip 地址
1. 进入容器内部后 cat /etc/hosts 会显示自己以及(– link)软连接的容器IP 2.使用命令 docker inspect --format '{{ .NetworkSetting ...
- 如何获取 docker 容器(container)的 ip 地址(转)
1. 进入容器内部后 cat /etc/hosts 会显示自己以及(– link)软连接的容器IP 2.使用命令 docker inspect --format '{{ .NetworkSetting ...
- Failed to start Docker Application Container
[root@localhost ~]# systemctl status docker.service ● docker.service - Docker Application Container ...
- [问题] docker: Failed to start Docker Application Container Engine.
docker无法启动: # systemctl restart docker Job for docker.service failed because the control process exi ...
- Failed to start Docker Application Container Engine.
[root@dockertest ~]# systemctl status docker.service● docker.service - Docker Application Container ...
- 014-docker-终端获取 docker 容器(container)的 ip 地址
1. 进入容器内部后 cat /etc/hosts 会显示自己以及(– link)软连接的容器IP 2.使用命令 docker inspect --format '{{ .NetworkSetting ...
- Docker 容器(container)及资源限制
Container: 既然container是由image运行起来的,那么是否可以理解为container和image有某种关系?先来看张图: 其实可以理解为container只是基于image之后的 ...
- 启动docker报Failed to start Docker Application Container Engine.解决
[root@docker ~]# systemctl status docker.service● docker.service - Docker Application Container Engi ...
- docker起不来报错:Failed to start Docker Application Container Engine.
报错信息如下: [root@localhost localdisk]# systemctl restart docker Job for docker.service failed because t ...
- docker开启remote-api 2375端口后,Failed to start Docker Application Container Engine,重启docker失败的问题解决
1. 按照网上的教程修改了 /usr/lib/systemd/system/docerk.service配置后,重启失败.修改/etc/docker/daemon.json 增加hosts后重启也是 ...
随机推荐
- Jmeter(三十一)Jmeter Question 之 乱码解读
众所周知,编码的问题影响着众多开发者,当然见多不怪. 先扒了一个编码的原因,也就是为什么要编码: 计算机中存储信息的最小单元是一个字节即 8 个 bit,所以能表示的字符范围是 0~255 个 人类要 ...
- css段落(后盾)
- Centos 7 下, 安装odoo 10
1. Centos在虚拟机中, 最小化安装, 网络连接选择的是 桥接模式, 安装完成后, 是不能直接上网的, 输入root 和密码, 登录进去, 然后执行: [root@localhost ~]# v ...
- BCGcontrolBar(三) 添加表格(Grid)组件
表格组件和图表组件是BCG的亮点之一 如下图 BCG有众多的表格样式可供选择 下图是插入基本表格组件后的效果 首先在程序中添加 BasicGridCtrl.h BasicGridCtrl.cpp 因为 ...
- Hibernate JPA 关联关系
Hibernate JPA 关联关系: 使用cascade做级联操作(只有在满足数据库约束时才会生效): CascadeType.PERSIST: 级联保存,只有调用persist()方法,才会级联保 ...
- (转)C#操作Word文档
原文1地址:http://www.cnblogs.com/lantionzy/archive/2009/10/23/1588511.html 原文2地址: http://www.cnblogs.com ...
- windows下使用gethostbyname函数报错无法解析的外部符号
#include <winsock.h> 使用gethostbyname的函数的时候,会显示无法解析的外部符号. 主要问题是因为没有引用WS2_32的lib库 在include上面引用就行 ...
- C#提取双引号中的字符串
public static void Main(string[] args) { string strtmp = "123\"456\"qqq\"789\&qu ...
- Windows Server 2016 启用完整版任务管理器
众所周知 Windows Server 2012以上的任务管理器是被阉割过的 那么如何启用呢?首先把你的任务管理器复制一份出来位置:系统盘\Windows\System32\Taskmgr.exe和系 ...
- git error: failed to push some refs to...
在git环境下push代码时,报错如下: 用gitk查看提交的信息,发现没有生产changeID,主要原因是clone项目时没有把hook克隆下来,解决办法:将项目clone地址的&& ...