资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

怎么运行docker容器

本篇内容介绍了“怎么运行docker容器”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

目前成都创新互联公司已为上1000家的企业提供了网站建设、域名、网站空间绵阳服务器托管、企业网站设计、枣庄网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

 首先我们查看下当前本地docker镜像:

[root@xinsz10 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

可以看到当前是没有任何镜像的,然后我们执行第二条命令,来拉取一个hello-world镜像

[root@xinsz10 ~]# docker pull hello-world
Using default tag: latest   

#相当于给我们的helloworld后面加 了一个:latest
latest: Pulling from library/hello-world  

#正在拉取library下的一个hello-world
Digest: sha256:b2ba691d8aac9e5ac3644c0788e3d3823f9e97f757f01d2ddc6eb5458df9d801
Status: Image is up to date for hello-world:latest

查看是否下载完成  也就是查看本地镜像

[root@xinsz10 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              05a3bd381fc2        4 weeks ago         1.84kB

注:  REPOSITORY 是镜像名

       IMAGE ID 是64位的字符串,这里自动被截掉了,只显示了16位,可以唯一标识我们的镜像

       CREATED   修改时间

        SIZE    大小

镜像的名字在网站上都可以查到,docker 提供了一个镜像仓库,hub.docker.com    默认到这里下载

镜像下载完成后,我们来看看如何运行

具体命令:  docker  run  +选项  IMAGE [:TAG] [命令] [ARG..]
[root@xinsz10 ~]# docker run hello-world
WARNING: IPv4 forwarding is disabled. Networking will not work.

Hello from Docker!
This message shows that your installation appears to be working correctly.  #如果这个消息显示出来说明你的安装已经OK了

下面这些英文,是在告诉我们docker运行时经过了那几个步骤
To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
根据上面弹出的英文提示,(关于docker执行docker run时所做的那些操作)
我们用示意图来看看docker pull和docker run的整个流程:

怎么运行docker容器

左边两个是在本机运行的,   最右面是远程镜像

docker pull会检查本机images里镜像是否存在,如果存在且版本正确,就直接用,如果不存在就从docker 仓库下载回来使用.

docker run也是一样,当执行这个命令时候,也需要到本地的images检查是否存在,不存在也会跟docker pull一样到远端去拉取镜像.

“怎么运行docker容器”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!


本文题目:怎么运行docker容器
URL分享:http://cdkjz.cn/article/gccjso.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220