docker 命令汇总

命令汇总

docker history fa5
fa5为镜像id或者镜像名

docker export 30b >h.tar
30b为容器id或者容器名
# docker export angry_bell > angry_bell.tar
# docker export --output=angry_bell-latest.tar angry_bell
# ls -sh angry_bell.tar
321M angry_bell.tar
# ls -sh angry_bell-latest.tar
321M angry_bell-latest.tar

docker import
与export是相反的

docker version
docker images -a
docker ps -a
docker top c94
docker stats c94 30b
docker port c94
列出端口映射,c94为容器id或者容器名

docker info
docker inspect
inspect vi. 进行检查;进行视察,vt. 检查;视察;检阅

docker logs c94

在A主机上操作
docker export 30b > htt.tar
docker save 192.168.1.22:5000/man > man.tar
scp man.tar 192.168.1.220:/root/

在B主机上操作
docker load --input man.tar

docker images -a
docker ps -a
docker info
docker rm container-id
docker rmi image-id

私服
yum install docker
docker ps
docker exec 0ae ls /usr/local/apache2/htdocs
docker exec 0ae cat /usr/local/apache2/htdocs/index.html
docker cp pycharm-community-2016.1.2.tar.gz  0ae:/usr/local/apache2/htdocs/
docker cp index.html 0ae:/usr/local/apache2/htdocs/
docker commit 0ae httpd-a
docker tag httpd-a localhost:5000/httpd-a
docker push localhost:5000/httpd-a

客户端
yum install docker
docker pull 192.168.1.22:5000/httpd-a
docker run -d -p 7965:80 192.168.1.22:5000/httpd-a

c/s本地与远程访问

vi /etc/sysconfig/docker
要使远程可以访问就加入-H 0.0.0.0:5555监听端口,否则就只能本地访问。
要本地与远程同时可以访问就加入-H 0.0.0.0:5555和-H unix:///var/run/docker.sock。
OPTIONS='-H 0.0.0.0:5555 --registry-mirror=http://a984be05.m.daocloud.io --selinux-enabled'

docker -H 192.168.1.22:5555 images
docker -H 192.168.1.22:5555 ps

While the docker commit command is a convenient way of extending an existing image, you should prefer the use of a Dockerfile and docker build for
generating images that you intend to share with other people.

======================================================

docker version

[root@kvm2 ff]# docker version
Client:
Version: 1.9.1
API version: 1.21
Package version: docker-common-1.9.1-40.el7.centos.x86_64
Go version: go1.4.2
Git commit: ab77bde/1.9.1
Built:
OS/Arch: linux/amd64 Server:
Version: 1.9.1
API version: 1.21
Package version: docker-common-1.9.1-40.el7.centos.x86_64
Go version: go1.4.2
Git commit: ab77bde/1.9.1
Built:
OS/Arch: linux/amd64

docker logs

docker logs记录了关于某个容器的输入与输出

[root@db ~]# docker logs b0b
[root@b0bcdb0f1a34 /]# ls
anaconda-post.log bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
[root@b0bcdb0f1a34 /]# cd /var/log
[root@b0bcdb0f1a34 log]# ls
anaconda yum.log
[root@b0bcdb0f1a34 log]# cat yum.log
Jun 17 07:59:22 Installed: groff-base-1.22.2-8.el7.x86_64
Jun 17 07:59:22 Installed: less-458-9.el7.x86_64
Jun 17 07:59:23 Installed: libpipeline-1.2.3-3.el7.x86_64
Jun 17 07:59:24 Installed: man-db-2.6.3-9.el7.x86_64
[root@b0bcdb0f1a34 log]# exit
exit
[root@db ~]# [root@kvm2 ff]# docker logs 949
[root@949737c56343 /]# pin
pinentry pinentry-curses ping ping6 pinky
[root@949737c56343 /]# pin
pinentry pinentry-curses ping ping6 pinky
[root@949737c56343 /]# ping www.baidu.com
PING www.baidu.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121: icmp_seq=1 ttl=51 time=20.6 ms
64 bytes from 61.135.169.121: icmp_seq=2 ttl=51 time=21.0 ms
^C
--- www.baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 20.675/20.855/21.036/0.231 ms [root@949737c56343 /]# ma
machinectl makedb mapfile
[root@949737c56343 /]# yum install man [root@949737c56343 /]# exit
exit
[root@949737c56343 /]#

docker export import save load

export 与 save出来的格式是不一样的

在A主机上操作
docker export 30b > htt.tar
docker save 192.168.1.22:5000/man > man.tar
scp man.tar 192.168.1.220:/root/ 在B主机上操作
docker load --input man.tar

docker info

[root@kvm2 ff]# docker info
Containers: 4
Images: 28
Server Version: 1.9.1
Storage Driver: devicemapper
Pool Name: docker-253:0-135997760-pool
Pool Blocksize: 65.54 kB
Base Device Size: 107.4 GB
Backing Filesystem:
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 1.029 GB
Data Space Total: 107.4 GB
Data Space Available: 45.39 GB
Metadata Space Used: 2.343 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.145 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.107-RHEL7 (2015-12-01)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.0-229.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 4
Total Memory: 7.593 GiB
Name: kvm2.zf.com
ID: J6FN:PCPE:UM27:RMDI:4EWG:5DUK:YWTA:EGDY:BNXQ:2E65:7TNK:COXF
Username: qq
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
上一篇:设计4个线程,其中两个线程每次对j增加1,另外两个线程对j每次减少1。写出程序。


下一篇:静态库、动态库文件制作