三Docker 基础用法
Posted zhuzhaoli
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了三Docker 基础用法相关的知识,希望对你有一定的参考价值。
3.1 search images
# docker search Ubuntu # 搜索镜像
3.2 pull images
# docker pull ubuntu # 获取 ubuntu 官方镜像
# docker images # 查看当前镜像列表
3.3 running an interactive shell
# docker run -i -t ubuntu:14.04 /bin/bash docker run -启动一个docker容器 -t - 分配一个(伪)tty (link is external) -i - 交互模式 (so we can interact with it) ubuntu:14.04 - 使用 ubuntu 基础镜像 14.04 /bin/bash - 运行命令 bash shell 注: ubuntu 会有多个版本,通过指定tag来启动特定的版本 [image]:[tag]运行命令测试
[[email protected] ~]# docker run -it centos:6 /bin/bash [[email protected] /]# ifconfig eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:04 inet addr:172.17.0.4 Bcast:0.0.0.0 Mask:255.255.0.0 inet6 addr: fe80::42:acff:fe11:4/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3 errors:0 dropped:0 overruns:0 frame:0 TX packets:5 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:238 (238.0 b) TX bytes:418 (418.0 b) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [[email protected] /]# cat /etc/centos-release CentOS release 6.10 (Final) [[email protected] /]# exit exit [[email protected] ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fa0101ec9408 centos:6 "/bin/bash" 36 seconds ago Exited (0) 5 seconds ago adoring_mestorf 635a6d6ecc18 centos:6 "/bin/bash" 3 minutes ago Exited (0) About a minute ago reverent_einstein bcd12a83d56a ubuntu:14.04 "/bin/bash" 11 minutes ago Exited (0) 8 minutes ago evil_meitner 3ea8b1a018bc hello-world "/hello" 51 minutes ago Exited (0) 51 minutes ago drunk_lumiere [[email protected] ~]# docker start fa0101ec9408 fa0101ec9408 [[email protected] ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fa0101ec9408 centos:6 "/bin/bash" About a minute ago Up 11 seconds adoring_mestorf 635a6d6ecc18 centos:6 "/bin/bash" 4 minutes ago Exited (0) 2 minutes ago reverent_einstein bcd12a83d56a ubuntu:14.04 "/bin/bash" 12 minutes ago Exited (0) 9 minutes ago evil_meitner 3ea8b1a018bc hello-world "/hello" 52 minutes ago Exited (0) 52 minutes ago drunk_lumiere [[email protected] ~]# docker stop fa0101ec9408 fa0101ec9408
以上是关于三Docker 基础用法的主要内容,如果未能解决你的问题,请参考以下文章