03_docker命令

2017-12-25  本文已影响0人  对方不想理你并向你抛出一个异常

查看

[root@hadoop ~]# docker info
Containers: 0
Images: 37
Server Version: 1.9.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 37
 Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.5-3.el6.x86_64
Operating System: <unknown>
CPUs: 1
Total Memory: 982.4 MiB
Name: hadoop
ID: GPVA:WPOI:422O:5YWJ:TZSN:ZY4P:HQHK:N7IO:BSED:AA6T:4G4B:BAD5
WARNING: No swap limit support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
[root@hadoop ~]# docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

下载、导入导出

运行

[root@hadoop ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
tomcat              latest              4f17b211b1a3        12 days ago         557.6 MB
centos              latest              a1f992ad364a        3 weeks ago         203.5 MB
[root@hadoop ~]# docker run centos:latest echo "hello world"
hello world

查看容器中的文件

[root@hadoop ~]# docker run centos:latest cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
[root@hadoop ~]# 
[root@hadoop ~]# docker run -i -t centos:latest /bin/bash
[root@b48f8f1133f4 /]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
[root@b48f8f1133f4 /]# 
[root@b48f8f1133f4 ssh]# exit
exit
[root@hadoop ~]# 
[root@hadoop ~]# docker run -tdi --privileged centos:latest /usr/sbin/init
9d8bdd656f840a3fad3c93b133a5fd181400708d6f3341460b71b82457f20023
[root@hadoop ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
9d8bdd656f84        centos:latest       "/usr/sbin/init"    19 seconds ago      Up 14 seconds                           backstabbing_goldberg
[root@hadoop ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
9d8bdd656f84        centos:latest       "/usr/sbin/init"    53 seconds ago      Up 48 seconds                           backstabbing_goldberg
[root@hadoop ~]# docker exec -it 9d8bdd656f84 /bin/bash             
[root@9d8bdd656f84 /]# ll
total 52
......
[root@9d8bdd656f84 /]# yum install -y openssh-server.x86_64
[root@9d8bdd656f84 /]# systemctl start sshd
[root@9d8bdd656f84 /]# ps aux|grep ssh
root        184  0.4  0.4 106000  4072 ?        Ss   17:53   0:00 /usr/sbin/sshd -D
root        186  0.0  0.0   9048   664 ?        S+   17:53   0:00 grep --color=auto ssh

关闭和删除

资料

Docker--命令使用详解
docker 操作命令详解

上一篇下一篇

猜你喜欢

热点阅读