设为首页 收藏本站
查看: 803|回复: 0

[经验分享] Docker安装使用

[复制链接]

尚未签到

发表于 2019-2-21 09:20:00 | 显示全部楼层 |阅读模式

  •   Docker版本及依赖的基础环境
    Docker版本
        双发行版

            docker-ee

            docker-ce

                moby

    依赖的基础环境
        64 bits CPU
        Linux Kernel 3.10+

        Linux Kernel cgroups and namespaces



  •   Docker安装方法
    1、CentOS Extras Repo

    2、Docker-CE
        下载:https://download.docker.com/
        仓库配置文件:https://download.docker.com/linux/centos/docker-ce.repo

  •   Docker程序环境
    环境配置文件:
            /etc/sysconfig/docker-network
            /etc/sysconfig/docker-storage
            /etc/sysconfig/docker
    Unit File:
            /usr/lib/systemd/system/docker.service
    Docker Registry配置文件:
            /etc/containers/registries.conf
    docker-ce:
            配置文件:/etc/docker/daemon.json
    Docker镜像加速
        Docker cn            
            {
                "registry-mirrors": ["https://registry.docker-cn.com"]
            }
        中国科技大学

        阿里云加速器            
            注册阿里云账号,专用加速器地址获得路径:
                https://cr.console.aliyun.com/#/accelerator

  •   Docker使用
    启动服务即可使用Docker
    systemctl start docker    Docker命令
    Usage:  docker [OPTIONS] COMMAND
    A self-sufficient runtime for containers
    Options:
          --config string      Location of client config files (default "/root/.docker")
      -D, --debug              Enable debug mode
      -H, --host list          Daemon socket(s) to connect to
      -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal")
                               (default "info")
          --tls                Use TLS; implied by --tlsverify
          --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
          --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
          --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
          --tlsverify          Use TLS and verify the remote
      -v, --version            Print version information and quit    Management Commands:   
          config      Manage Docker configs
          container   Manage containers
          image       Manage images
          network     Manage networks
          node        Manage Swarm nodes
          plugin      Manage plugins
          secret      Manage Docker secrets
          service     Manage services
          stack       Manage Docker stacks
          swarm       Manage Swarm
          system      Manage Docker
          trust       Manage trust on Docker images
          volume      Manage volumes    Commands:   
          attach      Attach local standard input, output, and error streams to a running container
          build       Build an image from a Dockerfile
          commit      Create a new image from a container's changes
          cp          Copy files/folders between a container and the local filesystem
          create      Create a new container
          diff        Inspect changes to files or directories on a container's filesystem
          events      Get real time events from the server
          exec        Run a command in a running container
          export      Export a container's filesystem as a tar archive
          history     Show the history of an image
          images      List images
          import      Import the contents from a tarball to create a filesystem image
          info        Display system-wide information
          inspect     Return low-level information on Docker objects
          kill        Kill one or more running containers
          load        Load an image from a tar archive or STDIN
          login       Log in to a Docker registry
          logout      Log out from a Docker registry
          logs        Fetch the logs of a container
          pause       Pause all processes within one or more containers
          port        List port mappings or a specific mapping for the container
          ps          List containers
          pull        Pull an image or a repository from a registry
          push        Push an image or a repository to a registry
          rename      Rename a container
          restart     Restart one or more containers
          rm          Remove one or more containers
          rmi         Remove one or more images
          run         Run a command in a new container
          save        Save one or more images to a tar archive (streamed to STDOUT by default)
          search      Search the Docker Hub for images
          start       Start one or more stopped containers
          stats       Display a live stream of container(s) resource usage statistics
          stop        Stop one or more running containers
          tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
          top         Display the running processes of a container
          unpause     Unpause all processes within one or more containers
          update      Update configuration of one or more containers
          version     Show the Docker version information
          wait        Block until one or more containers stop, then print their exit codes
        Run 'docker COMMAND --help' for more information on a command.    常用操作

查看docker相关的信息:
version
info
镜像:
images
rmi
pull
容器:
run:创建并运行一个容器;
create:创建一个容器;
start:启动一个处于停止状态容器;
创建:
create
run
启动:
start
停止:
kill
stop
重启:
restart
暂停和继续:
pause
unpause
删除容器:
rm
run --rm
创建容器:
基于“镜像文件”,
镜像文件有默认要运行的程序;
注意:
运行的容器内部必须有一个工作前台的运行的进程;
docker的容器的通常也是仅为运行一个程序;
要想在容器内运行多个程序,一般需要提供一个管控程序,例如supervised。
run, create
--name CT_NAME
--rm:容器运行终止即自行删除
--network BRIDGE:让容器加入的网络;
默认为docker0;
交互式启动一个容器:
-i:--interactive,交互式;
-t:Allocate a pseudo-TTY
从终端拆除:ctrl+p, ctrl+q
attach:附加至某运行状态的容器的终端设备;
exec:让运行中的容器运行一个额外的程序;
查看:
logs:Fetch the logs of a container,容器内部程序运行时输出到终端的信息;
ps:List containers
-a, --all:列出所有容器;
--filter, -f:过滤器条件显示
name=
status={stopped|running|paused}
stats:动态方式显示容器的资源占用状态:
top:Display the running processes of a container    容器状态及命令
        

    容器的状态:
        created
        runing
paused
stopped
deleted




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-675152-1-1.html 上篇帖子: 『中级篇』构建自己的Docker镜像(16) 下篇帖子: Docker容器技术入门
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表