docker 知识点


1、批量删除清理容器、镜像 v1.6以上版本支持docker ps -a -q 显示所有容器  docker ps -q 显示所有在运行的容器
    单个容器操作: 指定容器ID 或者容器 name

 docker kill $(docker ps -q) ;     强制kill 容器
 docker rm $(docker ps -a -q) ;    删除容器
 docker pause $(docker ps -q)      暂停容器
 docker unpause $(docker ps -q)    恢复暂停容器
 docker stop $(docker ps -q)       停止容器
 docker rmi $(docker images -q -a) 批量清除镜像

2、导入、导出容器
  
docker export <CONTAINER ID> > /home/export.tar            cat /home/export.tar |  docker import - m2015053101
3、导入、导出镜像

docker save busybox-1 > /home/save.tar                 docker load < /home/save.tar
4、使用 Device Mapper来改变Docker容器的默认存储空间大小 
http://cloud.51cto.com/art/201411/457439.htm

-------------------------------------------------------------------------------
5、Docker 后台进程参数

参数 介绍
--api-enable-cors=false 远程API调用。
-b, --bridge="" 桥接一个系统上的网桥设备到 Docker 容器里,当使用 none 可以停用容器里的网络
--bip="" 使用 CIDR 地址来设定网络桥的 IP。此参数和 -b 不能一起使用。
-D, --debug=false 开启Debug模式。例如:docker -d -D
-d, --daemon=false 开启Daemon模式。
--dns=[] 设置容器使用DNS服务器。例如: docker -d --dns 8.8.8.8
-dns-search=[] 设置容器使用指定的DNS搜索域名。如: docker -d --dns-search example.com
--exec-driver="native" 设置容器使用指定的运行时驱动。如:docker -d -e lxc
-G, --group="docker" 在后台运行模式下,赋予指定的Group到相应的unix socket上。注意,当此参数 --group 赋予空字符串时,将去除组信息
-g, --graph="/var/lib/docker" 设置Docker运行时根目录
-H, --host=[] 设置后台模式下指定socket绑定,可以绑定一个或多个 tcp://host:port, unix:///path/to/socket, fd://* 或 fd://socketfd。如:$ docker -H tcp://0.0.0.0:2375 ps 或者$ export DOCKER_HOST="tcp://0.0.0.0:2375"$ docker ps
-icc=true 设置启用内联容器的通信。
--ip="0.0.0.0" 设置容器绑定IP时使用的默认IP地址
--ip-forward=true 设置启动容器的 net.ipv4.ip_forward
--iptables=true 设置启动Docker容器自定义的iptable规则
--mtu=0 设置容器网络的MTU值,如果没有这个参数,选用默认 route MTU,如果没有默认route,就设置成常量值 1500。
-p, --pidfile="/var/run/docker.pid" 设置后台进程PID文件路径。
-r, --restart=true 设置重启之前运行中的容器
-s, --storage-driver="" 设置容器运行时使用指定的存储驱动,如,指定使用devicemapper,可以这样:docker -d -s devicemapper
--selinux-enabled=false 设置启用selinux支持
--storage-opt=[] 设置存储驱动的参数
--------------------------------------------------------------------------------------------
centos7.0 版本下安装docker   
yum install docker 

##
docker 文件存储驱动简介

Aufs  实现起来比较简单,但是由于其迟迟不能加入linux内核,导致兼容性差。目前,仅有Ubuntu支持。
Devicemapper  虽然实现起来复杂,但兼容性好。其存在的一点不足是,当metadata和data空间被耗尽时,需要重启Docker来扩充空间。


6、更改docker 启动参数
             --storage-opt=dm.basesize=60G 指定容器默认存贮空间大小 
             --storage-opt=dm.loopdatasize=256G docker存储池大小  
             --storage-opt=dm.loopmetadatasize=10G  容器元数据存储池大小 
  注意:如果/var/lib/docker 已有相关存储池,需要删除,重启docker 方能生效,否则会继续使用之前的。

7、/etc/sysconfig/docker 包含docker守护进程的参数 网络 存储 系统等参数配置。

8、docker attach 进入容器,exit退出时候,容器也会停止运行。
   docker exec -it ID /bin/bash  进入容器,bash环境。 
   docker inspect ID  获取容器的元数据
                      -f 此参数 可以以go预定义模板组织数据 
                 例:docker inspect ${{.Name}} id 获取容器名称

9、指定docker文件驱动 -s  默认devicemapper 可选aufs




-----------------------------------------------------------------------------------------------------------------------
docker 仓库部署

版本  1.6及以上
1、官方仓库镜像  docker  pull registry

2、启动仓库容器 docker run -d -p 5000:5000 --restart=always --name registry registry:2
         可选选项:  -v /data:/var/lib/registry  映射存储目录
  
3、  docker run -d -p 5000:5000 --restart=always --name registry \
  -v `pwd`/certs:/certs \
  -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
  -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
  registry:2
  启用加密连接,允许其他主机访问,下载镜像。

----------------------------------------------------------------------
docker file
需要注意:

1、ENTRYPOINT,表示镜像在初始化时需要执行的命令,不可被重写覆盖,需谨记
2、CMD,表示镜像运行默认参数,可被重写覆盖
3、ENTRYPOINT/CMD都只能在文件中存在一次,并且最后一个生效 多个存在,只有最后一个生效,其它无效!
4、需要初始化运行多个命令,彼此之间可以使用 && 隔开,但最后一个须要为无限运行的命令,需切记!
5、docker file  支持向dockerfile中传入变量 
                 docker build --build-arg port=8012  传入port 端口



————————————————————————————————————————————————————

centos7.0 
安装salt
curl -o install_salt.sh -L https://bootstrap.saltstack.com
sudo sh install_salt.sh -M git develop

客户端
curl -o install_salt.sh -L https://bootstrap.saltstack.com
sudo sh install_salt.sh  git develop



-------------------------------------------------------------------------

注意 docker 开启内存 cpu 控制,需要centos7 系统下开启如下配置参数


If you want to enable memory and swap accounting, you must add the following command-line parameters to your kernel:

$ cgroup_enable=memory swapaccount=1

On systems using GRUB (which is the default for Ubuntu), you can add those parameters by editing /etc/default/grub and extending GRUB_CMDLINE_LINUX. Look for the following line:

$ GRUB_CMDLINE_LINUX=""


-------------------------------------

And replace it by the following one:

$ GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"

Then run sudo update-grub, and reboot.

-----------------------------------------------------------------

Pingbacks已打开。

Trackbacks
  1. Make Time 发布于 2020年11月30日 05:41 #

    WUMN - docker 知识点

引用地址

评论
  1. Car Insurance Quotes Utah Car Insurance Quotes Utah 发布于 2020年11月30日 01:46 #

    Hi there, just wanted to mention, I liked this blog post.
    It was funny. Keep on posting!

  2. blackjack online real money blackjack online real money 发布于 2020年11月30日 01:48 #

    online casinos taking us players
    legal online casinos
    bingo websites usa

  3. voip voip 发布于 2020年11月30日 02:05 #

    I am actually pleased to read this blog posts which includes lots
    of useful data, thanks for providing such statistics.

  4. voip voip 发布于 2020年11月30日 02:05 #

    I am actually pleased to read this blog posts which includes lots of
    useful data, thanks for providing such statistics.

  5. visite my wep site visite my wep site 发布于 2020年11月30日 02:41 #

    I enjoy what you guys tend to be up too. This kind of clever work and coverage!

    Keep up the fantastic works guys I've included you
    guys to my personal blogroll.

  6. visite my wep site visite my wep site 发布于 2020年11月30日 02:41 #

    I enjoy what you guys tend to be up too. This kind of clever
    work and coverage! Keep up the fantastic works guys I've
    included you guys to my personal blogroll.

  7. Cullinan Cullinan 发布于 2020年11月30日 02:44 #

    Howdy this is somewhat of off topic but I was wanting to know if blogs
    use WYSIWYG editors or if you have to manually code
    with HTML. I'm starting a blog soon but have no coding expertise so I wanted to get guidance from someone with experience.
    Any help would be enormously appreciated!

  8. Cullinan Cullinan 发布于 2020年11月30日 02:45 #

    Howdy this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG
    editors or if you have to manually code with HTML. I'm starting a blog soon but have
    no coding expertise so I wanted to get guidance from someone with experience.
    Any help would be enormously appreciated!

  9. web site web site 发布于 2020年11月30日 02:50 #

    Everyone loves what you guys tend to be up too.
    Such clever work and reporting! Keep up the very
    good works guys I've incorporated you guys to my personal blogroll.

    web site

  10. Marquita Marquita 发布于 2020年11月30日 03:01 #

    Excellent post. I absolutely love this website.
    Stick with it!

  11. Marquita Marquita 发布于 2020年11月30日 03:02 #

    Excellent post. I absolutely love this website. Stick
    with it!

  12. Free Sex Movies Free Sex Movies 发布于 2020年11月30日 04:14 #

    No matter if some one searches for his vital thing, therefore he/she desires to be available that
    in detail, so that thing is maintained over here.

  13. Free Sex Movies Free Sex Movies 发布于 2020年11月30日 04:14 #

    No mattter if some one searches for his vital thing, therefore he/she desires to be available that in detail, so that thing is maintained over
    here.

  14. 온라인카지노 온라인카지노 发布于 2020年11月30日 06:06 #

    Hello, i think that i saw you visited my blog so i came to
    “return tthe favor”.I'm trying to find things to
    improve my website!I suppose its ok to uuse some of your ideas!!

  15. 온라인카지노 온라인카지노 发布于 2020年11月30日 06:06 #

    Hello, i think that i saw you visited my
    blkg so i came to “return the favor”.I'm trying to find things to improve my website!I suppose its ok to use
    some of your ideas!!

  16. https://savorlondonmassage.co.uk https://savorlondonmassage.co.uk 发布于 2020年11月30日 06:21 #

    Superb, what a weblog it is! This blog presents helpful information to us,
    keep it up.

  17. https://savorlondonmassage.co.uk https://savorlondonmassage.co.uk 发布于 2020年11月30日 06:21 #

    Superb, what a weblog it is! This blog presents helpful information to
    us, keep it up.

  18. Peer to Peer Peer to Peer 发布于 2020年11月30日 06:41 #

    This piece of writing is truly a fastidious one it helps
    new the web users, who are wishing in favor of blogging.

  19. 우리카지노 우리카지노 发布于 2020年11月30日 07:18 #

    Prety nice post. I just stumbled upon your blog andd wanted too say that
    I've truly enjoyed browsing your blog posts. In any case
    I'll be subscribing to your rss feed and I hope you write
    again soon!

  20. 우리카지노 우리카지노 发布于 2020年11月30日 07:19 #

    Pretty nice post. I just stumbled upon your blog andd wanted to
    say tuat I've truly enjjoyed browsing your blog posts.
    In any case I'll be subscribing tto yoour rss feed and I hope you write again soon!

  21. vay tín chấp ngân hàng akulaku vay tín chấp ngân hàng akulaku 发布于 2020年11月30日 07:23 #

    Hello there! Do you know if they make any plugins to protect against hackers?
    I'm kinda paranoid about losing everything I've worked
    hard on. Any suggestions?

  22. vay tín chấp ngân hàng akulaku vay tín chấp ngân hàng akulaku 发布于 2020年11月30日 07:23 #

    Hello there! Do you know if they make any plugins to protect against hackers?

    I'm kinda paranoid about losing everything I've
    worked hard on. Any suggestions?

  23. auodio book auodio book 发布于 2020年11月30日 07:33 #

    Because the admin of this site is working,
    no hesitation very shortly it will be renowned, due to its quality contents.

  24. auodio book auodio book 发布于 2020年11月30日 07:34 #

    Because the admin of this site is working,
    no hesitation very shortly it will be renowned, due to its quality contents.

  25. 德国运营 德国运营 发布于 2020年11月30日 07:59 #

    Hi, yup this article is really good and I have learned lot
    of things from it about blogging. thanks.

  26. 德国运营 德国运营 发布于 2020年11月30日 07:59 #

    Hi, yup this article is really good and I have learned
    lot of things from it about blogging. thanks.

  27. boite de déménagement boite de déménagement 发布于 2020年11月30日 08:06 #

    Hello! Do you know if they make any plugins to assist with SEO?
    I'm trying to get my blog to rank for some targeted keywords but
    I'm not seeing very good results. If you know of any please share.

    Kudos!

  28. Buy Property in Nigeria Buy Property in Nigeria 发布于 2020年11月30日 08:17 #

    You really make it seem so easy with your presentation but
    I find this matter to be actually something which I think I would never understand.
    It seems too complicated and extremely broad for me. I'm looking forward for your next post, I'll try to get the hang
    of it!

  29. Buy Property in Nigeria Buy Property in Nigeria 发布于 2020年11月30日 08:17 #

    You really make it seem so easy with your presentation but I find this matter to be actually something
    which I think I would never understand. It seems too complicated and extremely broad for me.
    I'm looking forward for your next post, I'll try to get the hang of it!

  30. bedding bedding 发布于 2020年11月30日 08:33 #

    All products and services featured are independently selected by
    Forbes Shopping contributors and editors.

    When you make a purchase through links on this page,
    we may earn a commission.

  31. bedding bedding 发布于 2020年11月30日 08:33 #

    All products and services featured are independently selected by Forbes Shopping contributors and editors.
    When you make a purchase through links on this page, we may earn a commission.

  32. bisnis online tanpa modal bisnis online tanpa modal 发布于 2020年11月30日 08:45 #

    I got this site from my friend who informed me concerning this web page and now this time I am visiting this
    web page and reading very informative content at this time.

  33. bisnis online tanpa modal bisnis online tanpa modal 发布于 2020年11月30日 08:46 #

    I got this site from my friend who informed me concerning
    this web page and now this time I am visiting this web page and reading very informative content at
    this time.

  34. Julpyssel Julpyssel 发布于 2020年11月30日 09:05 #

    Thanks for some other excellent article. Where else could anyone
    get that kind of info in such a perfect method of writing?
    I have a presentation next week, and I'm on the look for such info.

  35. Julpyssel Julpyssel 发布于 2020年11月30日 09:05 #

    Thanks for some other excellent article. Where else could
    anyone get that kind of info in such a perfect method of
    writing? I have a presentation next week, and
    I'm on the look for such info.

  36. https://bibliocrunch.com/profile/vaytientragop/ https://bibliocrunch.com/profile/vaytientragop/ 发布于 2020年11月30日 09:20 #

    Having read this I believed it was very informative.
    I appreciate you spending some time and energy to put this article together.
    I once again find myself personally spending way too much time both reading and posting comments.
    But so what, it was still worthwhile!

  37. https://bibliocrunch.com/profile/vaytientragop/ https://bibliocrunch.com/profile/vaytientragop/ 发布于 2020年11月30日 09:21 #

    Having read this I believed it was very informative. I appreciate you spending some time and
    energy to put this article together. I once again find myself
    personally spending way too much time both reading and posting comments.

    But so what, it was still worthwhile!

发表评论