docker之操作管理应用模板、镜像、容器、构建基础镜像、状态删除

五、Docker操作管理

1.应用模板

(1)Concrete5

通过“应用商店”部署Concrete5,修改网页访问端口为9091,通过curl命令访问首页,提交执行结果文本到命令行界面。

# curl http://192.168.200.11:9091/                     

   

   

       

xiandian :: Home

 

   

   

 

 

   

       

           

                           

           

                           

                   

   

       

   

        

           

                       

           

                           

           

                           

       

   

   

   

       

           

                Built with concrete5 CMS.

               

                    Log in               

           

       

   

通过“应用商店”部署Concrete5,修改网页访问端口为9091,通过links命令访问index.php页面,提交执行结果文本到命令行界面。

# links  http://10.0.6.81:9091/index.php

                  xiandian :: Home

   Built with concrete5 CMS. Log in                                                                                                      

 http://www.concrete5.org/                                                                                                        [------]

(2)Ghost

通过“应用商店”部署Ghost,修改网页访问端口为9092通过curl命令访问首页,提交执行结果文本到命令行界面。

[root@registry 6-4]# curl 192.168.200.11:9092

   

   

    Ghost

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

       

            

Ghost

           

Just a blogging platform.

       

   

   

   

   

    

       

Welcome to Ghost

   

   

       

You're live! Nice. We've put together a little post to introduce you to the Ghost editor and get you started. You can manage your content by »

   

   

       

           

           

Proudly published with Ghost

       

   

   

   

   

通过“应用商店”部署Ghost,修改网页访问端口为9092通过links命令访问首页,提交执行结果文本到命令行界面。

# links  http://10.0.6.81:9092

                                                                                                                                    Ghost

   Link: canonical                                                                                                                        

   Link: Ghost (alternate)                                                                                                               

  Menu                                                                                                                                    

   Close                                                                                                                                 

     * Home                                                                                                                               

   Subscribe                                                                                                                             

   Menu                                                                                                                                   

                                                                  Ghost                                                                  

Just a blogging platform.                                                                                                                 

   Scroll Down                                                                                                                           

   Page 1 of 1                                                                                                                           

Welcome to Ghost                                                                                                                          

   You're live! Nice. We've put together a little post to introduce you to the Ghost editor and get you started. You can manage your     

   content by »                                                                                                                           

                                                                                                                                         

   Ghost Owner on Getting Started 27 March 2017 Page 1 of 1 Ghost © 2017 Proudly published with Ghost                                    

                                                                                                                                      

http://localhost:2368/                                                                                                           [------]

(3)Gogs

通过“应用商店”部署Gogs,修改网页访问端口为9093,通过curl命令访问用户列表,提交执行结果文本到命令行界面。

# curl -L http://192.168.200.11:9093/explore/users

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

        Explore - XianDian

        

       

               

                       

                                

                                       

                                               

                                                       

                                               

                                       

                               

                        

       

               

                       

                       

                               

       

         

         

       

                               

 

                                               

                                                  

                                                 

                                                        xiandian

                                                   

                                                                        Joined on Mar 27, 2017

                                                   

                                                 

                                               

 

                               

                       

               

       

 

       

       

               

                       

                                © 2016 Gogs Version: 0.9.100.1119 Page: 3ms Template: 0ms

                       

                        Website

                                Go1.5.4

                        

               

       

(4)Grafana

通过“应用商店”部署Grafana,修改网页访问端口为9094,通过curl命令访问首页,提交执行结果文本到命令行界面。

# curl  -u admin:password  http://192.168.200.11:9094

 

   

   

   

    

    Grafana

               

                 

   

               

       

       

               

                       

                       

                               

                                       

                                       

{{alert.title}}

                                       

                               

                       

                        

                       

               

       

        

      

通过“应用商店”部署Grafana,修改网页访问端口为9094,通过links命令访问首页,提交执行结果文本到命令行界面。

# links  http://10.0.6.81:9094

                                                                                                                                  Grafana

   {{alert.title}}                                                                                                                        

                                                                                                                                         

     * Docs                                                                                                                              

     * Support Plans                                                                                                                      

     * Community                                                                                                                         

     * Grafana v4.0.0 (commit: v4.0.0)                                                                                                    

     * New version available!                                                                                                             

(5)Jenkis

通过“应用商店”部署Jenkis,修改网页访问端口为9095,创建一个名为xiandian的job,通过curl命令访问这个项目的首页,提交执行结果文本到命令行界面。

Delete Project

collapse
100%
Build History

# curl http://192.168.200.11:9095/job/xiandian/

x

Project xiandian

Workspace
Recent Changes
Page generated: Mar 28, 2017 7:55:17 AM UTCREST APIJenkins ver. 1.651.3

通过“应用商店”部署Jenkis,修改网页访问端口为9095,创建一个名为xiandian的job,通过links命令访问这个项目的首页,提交执行结果文本到命令行界面。

# links  http://10.0.6.81:9095/job/xiandian/

                                                                                                                 xiandian [Jenkins] (2/2)

   trend                                                                                                                                  

   100%Build History                                                                                                                      

   x _____________________                                                                                                               

   Feed RSS for all Feed RSS for failures                                                                                                 

                                                             Project xiandian                                                            

   xiandian                                                                                                                               

                                                                                                                  [IMG]edit description  

                                                                                                                    [ Disable Project ]  

   [IMG] Workspace                                                                                                                        

   [IMG] Recent Changes                                                                                                                  

Permalinks                                                                                                                                

   Page generated: Mar 30, 2017 5:47:12 AM UTCREST APIJenkins ver. 1.651.3                                                               

   [IMG] Help us localize this page                                                                                                       

(6)Owncloud

通过“应用商店”部署Owncloud,修改网页访问端口为9096,通过curl命令访问首页,提交执行结果文本到命令行界面。

# curl  -L  http://192.168.200.11:9096

       

               

                </p> <p>                ownCloud               

               

               

               

               

               

               

       

               

                        This application requires JavaScript for correct operation. Please enable JavaScript and reload the page.  

       

               

                        

                                                                       

                                               

                                        

       

                                                                       

               

                       

                                placeholder="Username or email"

                                value=""

                                autofocus                               autocomplete="on" autocapitalize="off" autocorrect="off" required>

                        

               

               

                       

                                placeholder="Password"

                                                                autocomplete="on" autocapitalize="off" autocorrect="off" required>

                       

                       

               

 

                                               

                                

               

               

       

                               

                        

               

               

                       

                                ownCloud – web services under your control                 

               

       

(7)RocketChat

通过“应用商店”部署RocketChat,修改网页访问端口为9097,通过inspect命令查看该服务的配置信息,提交执行结果文本到命令行界面。

# docker inspect 4c55d007c682      

[

    {

        "Id": "4c55d007c682d148464dd8eb058b675bb69c03e6321e1a2055b180c9c94df17a",

        "Created": "2017-03-27T05:39:03.375787951Z",

        "Path": "node",

        "Args": [

            "main.js"

        ],

        "State": {

            "Status": "running",

            "Running": true,

            "Paused": false,

            "Restarting": false,

            "OOMKilled": false,

            "Dead": false,

            "Pid": 21746,

            "ExitCode": 0,

            "Error": "",

            "StartedAt": "2017-03-27T05:39:07.529597908Z",

            "FinishedAt": "0001-01-01T00:00:00Z"

        },

        "Image": "sha256:786192493b9636f621b8b833cbdacbd0926a70a8ebf8fdebc593a772dd1d0015",

        "ResolvConfPath": "/var/lib/docker/containers/4c55d007c682d148464dd8eb058b675bb69c03e6321e1a2055b180c9c94df17a/resolv.conf",

        "HostnamePath": "/var/lib/docker/containers/4c55d007c682d148464dd8eb058b675bb69c03e6321e1a2055b180c9c94df17a/hostname",

        "HostsPath": "/var/lib/docker/containers/4c55d007c682d148464dd8eb058b675bb69c03e6321e1a2055b180c9c94df17a/hosts",

        "LogPath": "",

        "Name": "/963581eb-74cd-4a2a-91ca-e3afbdc884fa",

        "RestartCount": 0,

        "Driver": "devicemapper",

        "MountLabel": "",

        "ProcessLabel": "",

        "AppArmorProfile": "",

        "ExecIDs": null,

        "HostConfig": {

            "Binds": null,

            "ContainerIDFile": "",

            "LogConfig": {

                "Type": "journald",

                "Config": {}

            },

            "NetworkMode": "default",

            "PortBindings": {

                "3000/tcp": [

                    {

                        "HostIp": "",

                        "HostPort": "3000"

                    }

                ]

            },

            "RestartPolicy": {

                "Name": "",

                "MaximumRetryCount": 0

            },

            "VolumeDriver": "",

            "VolumesFrom": null,

            "CapAdd": null,

            "CapDrop": null,

            "Dns": [

                "169.254.169.250"

            ],

            "DnsOptions": null,

            "DnsSearch": [

                "openstacklocal",

                "rocket-chat.rancher.internal",

                "rocketchat.rocket-chat.rancher.internal",

                "rancher.internal"

            ],

            "ExtraHosts": null,

            "GroupAdd": null,

            "IpcMode": "",

            "Links": null,

            "OomScoreAdj": 0,

            "PidMode": "",

            "Privileged": false,

            "PublishAllPorts": false,

            "ReadonlyRootfs": false,

            "SecurityOpt": null,

            "UTSMode": "",

            "ShmSize": 67108864,

            "ConsoleSize": [

                0,

                0

            ],

            "Isolation": "",

            "CpuShares": 0,

            "CgroupParent": "",

            "BlkioWeight": 0,

            "BlkioWeightDevice": null,

            "BlkioDeviceReadBps": null,

            "BlkioDeviceWriteBps": null,

            "BlkioDeviceReadIOps": null,

            "BlkioDeviceWriteIOps": null,

            "CpuPeriod": 0,

            "CpuQuota": 0,

            "CpusetCpus": "",

            "CpusetMems": "",

            "Devices": null,

            "KernelMemory": 0,

            "Memory": 0,

            "MemoryReservation": 0,

            "MemorySwap": 0,

            "MemorySwappiness": -1,

            "OomKillDisable": false,

            "PidsLimit": 0,

            "Ulimits": null

        },

        "GraphDriver": {

            "Name": "devicemapper",

            "Data": {

                "DeviceId": "297",

                "DeviceName": "docker-253:1-335544513-425c8a0755ee9d0b0543ca613cfa2d13a921383aa15bf5867d6437e4cede3586",

                "DeviceSize": "10737418240"

            }

        },

        "Mounts": [

            {

                "Name": "e27625cd53341f3f4afdc6e713f0e93483b32481e3865017454a0416324ed870",

                "Source": "/var/lib/docker/volumes/e27625cd53341f3f4afdc6e713f0e93483b32481e3865017454a0416324ed870/_data",

                "Destination": "/app/uploads",

                "Driver": "local",

                "Mode": "",

                "RW": true,

                "Propagation": ""

            }

        ],

        "Config": {

            "Hostname": "4c55d007c682",

            "Domainname": "",

            "User": "rocketchat",

            "AttachStdin": false,

            "AttachStdout": false,

            "AttachStderr": false,

            "ExposedPorts": {

                "3000/tcp": {}

            },

            "Tty": false,

            "OpenStdin": false,

            "StdinOnce": false,

            "Env": [

                "MONGO_PORT=tcp://mongo:27017",

                "ROCKET_CHAT_MONGO_1_PORT=tcp://mongo:27017",

                "MONGO_1_PORT_27017_TCP_PORT=27017",

                "MONGO_ENV_MONGO_MAJOR=3.4",

                "MONGO_ENV_MONGO_PACKAGE=mongodb-org",

                "ROCKET_CHAT_MONGO_1_ENV_GOSU_VERSION=1.7",

                "MONGO_PORT_27017_TCP=tcp://mongo:27017",

                "MONGO_PORT_27017_TCP_ADDR=mongo",

                "ROCKET_CHAT_MONGO_1_PORT_27017_TCP_PORT=27017",

                "ROCKET_CHAT_MONGO_1_NAME=/cattle/rocket-chat_mongo_1",

                "MONGO_ENV_GOSU_VERSION=1.7",

                "PORT=3000",

                "MONGO_1_PORT_27017_TCP=tcp://mongo:27017",

                "MONGO_PORT_27017_TCP_PORT=27017",

                "ROCKET_CHAT_MONGO_1_PORT_27017_TCP_PROTO=tcp",

                "ROCKET_CHAT_MONGO_1_ENV_MONGO_MAJOR=3.4",

                "ROOT_URL=http://yourhost:3000",

                "ROCKET_CHAT_MONGO_1_ENV_MONGO_VERSION=3.4.0",

                "MONGO_ENV_MONGO_VERSION=3.4.0",

                "ROCKET_CHAT_MONGO_1_ENV_MONGO_PACKAGE=mongodb-org",

                "MONGO_1_NAME=/cattle/mongo_1",

                "MONGO_1_ENV_MONGO_VERSION=3.4.0",

                "ROCKET_CHAT_MONGO_1_PORT_27017_TCP=tcp://mongo:27017",

                "MONGO_PORT_27017_TCP_PROTO=tcp",

                "MONGO_1_ENV_MONGO_PACKAGE=mongodb-org",

                "MONGO_1_PORT=tcp://mongo:27017",

                "MONGO_1_PORT_27017_TCP_ADDR=mongo",

                "MONGO_1_PORT_27017_TCP_PROTO=tcp",

                "MONGO_1_ENV_MONGO_MAJOR=3.4",

                "MONGO_NAME=/cattle/mongo",

                "ROCKET_CHAT_MONGO_1_PORT_27017_TCP_ADDR=mongo",

                "MONGO_URL=mongodb://mongo:27017/rocketchat",

                "MONGO_1_ENV_GOSU_VERSION=1.7",

                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",

                "NODE_VERSION=4.6.2",

                "NODE_ENV=production",

                "RC_VERSION=latest",

                "HOME=/tmp",

                "Accounts_AvatarStorePath=/app/uploads"

            ],

            "Cmd": [

                "node",

                "main.js"

            ],

            "Image": "rocketchat/rocket.chat:latest",

            "Volumes": {

                "/app/uploads": {}

            },

            "WorkingDir": "/app/bundle",

            "Entrypoint": null,

            "MacAddress": "02:99:77:08:ab:71",

            "OnBuild": null,

            "Labels": {

                "io.rancher.container.ip": "10.42.206.204/16",

                "io.rancher.container.name": "rocket-chat_rocketchat_1",

                "io.rancher.container.uuid": "963581eb-74cd-4a2a-91ca-e3afbdc884fa",

                "io.rancher.project.name": "rocket-chat",

                "io.rancher.project_service.name": "rocket-chat/rocketchat",

                "io.rancher.service.deployment.unit": "4768a84b-6987-47dc-99fa-a7aa75cc79fa",

                "io.rancher.service.hash": "8977397abec00b351475ed4482806bcd88169263",

                "io.rancher.service.launch.config": "io.rancher.service.primary.launch.config",

                "io.rancher.stack.name": "rocket-chat",

                "io.rancher.stack_service.name": "rocket-chat/rocketchat"

            }

        },

        "NetworkSettings": {

            "Bridge": "",

            "SandboxID": "de88d7e2d9ea62c9fb4107dddf88f051e50e32f471ebdf4c2d153c5e76737f52",

            "HairpinMode": false,

            "LinkLocalIPv6Address": "",

            "LinkLocalIPv6PrefixLen": 0,

            "Ports": {

                "3000/tcp": [

                    {

                        "HostIp": "0.0.0.0",

                        "HostPort": "3000"

                    }

                ]

            },

            "SandboxKey": "/var/run/docker/netns/de88d7e2d9ea",

            "SecondaryIPAddresses": null,

            "SecondaryIPv6Addresses": null,

            "EndpointID": "319d689aaefd09f4b46ff808738e94b2bf03b56ee9b0e22d803a6d64afe86617",

            "Gateway": "172.17.0.1",

            "GlobalIPv6Address": "",

            "GlobalIPv6PrefixLen": 0,

            "IPAddress": "172.17.0.17",

            "IPPrefixLen": 16,

            "IPv6Gateway": "",

            "MacAddress": "02:99:77:08:ab:71",

            "Networks": {

                "bridge": {

                    "IPAMConfig": null,

                    "Links": null,

                    "Aliases": null,

                    "NetworkID": "706c806378aa62e5535ae7da77d35e5b06ec8ed1d72e1e0297656db041ead85a",

                    "EndpointID": "319d689aaefd09f4b46ff808738e94b2bf03b56ee9b0e22d803a6d64afe86617",

                    "Gateway": "172.17.0.1",

                    "IPAddress": "172.17.0.17",

                    "IPPrefixLen": 16,

                    "IPv6Gateway": "",

                    "GlobalIPv6Address": "",

                    "GlobalIPv6PrefixLen": 0,

                    "MacAddress": "02:99:77:08:ab:71"

                }

            }

        }

    }

]

(8)Wordpress

通过“应用商店”部署Wordpress,修改网页访问端口为9098,通过curl命令访问首页,提交执行结果文本到命令行界面。

# curl  -U admin:000000 http://192.168.200.11:9098/

       

       

       

               

XianDian – 又一个WordPress站点

 

               

               

       

               

               

               

       

               

      

               

世界,您好!

   

       

               

欢迎使用WordPress。这是您的第一篇文章。编辑或删除它,然后开始写作吧!

       

       

               

       

       

               

               

                       

                                                                XianDian

                                Proudly powered by WordPress

                       

                

       

(9)自定义构建

利用rancher的应用栈,手工构建一个服务,手工添加一个名叫xd-db的数据库服务,添加两个名为xd-wp的wordpress服务,完成后创建一个名为xd-lb的负载均衡器,绑定外部端口为18888,完成后提交此应用栈的docker-compose.yml文件和rancher-compose.yml文件,将以上操作命令及检查结果填入命令行界面。

docker-compose.yml

xd-wp:

  labels:

    io.rancher.container.pull_image: always

  tty: true

  hostname: wordpress

  image: 192.168.200.12:5000/wordpress:latest

  links:

  - xd-db:mysql

  privileged: true

  stdin_open: true

xd-db:

  environment:

    MYSQL_ROOT_PASSWORD: '000000'

  labels:

    io.rancher.container.pull_image: always

  tty: true

  hostname: mariadb_server

  image: 192.168.200.12:5000/mariadb:latest

  privileged: true

  stdin_open: true

xd-lb:

  ports:

  - 18888:80

  tty: true

  image: rancher/load-balancer-service

  links:

  - xd-wp:xd-wp

  stdin_open: true

rancher-compose.yml

xd-wp:

  scale: 2

xd-db:

  scale: 1

xd-lb:

  scale: 1

  load_balancer_config:

    haproxy_config: {}

  health_check:

    port: 42

    interval: 2000

    unhealthy_threshold: 3

    healthy_threshold: 2

    response_timeout: 2000

2.镜像

(1)获取

在server节点拉取mariadb镜像,拉取完成后查询docker镜像列表目录,将以上操作命令及检查结果填入命令行界面。

[root@server ~]# docker pull mariadb:latest

Trying to pull repository 192.168.200.12:5000/mariadb ...

latest: Pulling from 192.168.200.12:5000/mariadb

386a066cd84a: Pull complete

827c8d62b332: Pull complete

de135f87677c: Pull complete

05822f26ca6e: Pull complete

ad65f56a251e: Pull complete

d71752ae05f3: Pull complete

87cb39e409d0: Pull complete

8e300615ba09: Pull complete

411bb8b40c58: Pull complete

f38e00663fa6: Pull complete

7b8e0ed6d4af: Pull complete

9a599d94dc41: Pull complete

Digest: sha256:7f9f59d0009c2c0b1a3446ef832bc4a46b64d17963aa1adf590b2793a9f95ceb

Status: Downloaded newer image for 192.168.200.12:5000/mariadb:latest

[root@server ~]# docker images

REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE

192.168.200.12:5000/mariadb               latest              66498efd6bd8        4 months ago        389.9 MB

(2)修改

在registry节点运行mariadb镜像,设置数据库密码为xd_root,将宿主机13306端口作为容器3306端口映射,进入容器后创建数据库xd_db,创建用户xiandian,密码为xd_pass,将此用户对xd_db拥有所有权限和和允许此用户远程访问,完成后使用xiandian用户远程登录数据库查询数据库内的数据库列表,将以上操作命令及检查结果填入命令行界面。

# docker run -itdP -e MYSQL_ROOT_PASSWORD=xd_root -p 13306:3306 192.168.200.12:5000/mariadb:latest

# docker exec -it 8998a53f34da /bin/bash

# mysql -uroot -pxd_root

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 2

Server version: 10.1.19-MariaDB-1~jessie mariadb.org binary distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database xd_db;

Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> grant all privileges on xd_db.* to 'xiandian'@'%'  identified by 'xd_pass';

Query OK, 0 rows affected (0.00 sec)

# mysql -uxiandian -pxd_pass -h172.17.0.66 -e "show databases;"

+--------------------+

| Database           |

+--------------------+

| information_schema |

| xd_db              |

+--------------------+

(3)导出

在server节点将修改的mariadb镜像导出,导出名称为mariadb_images.tar,将以上操作命令及检查结果填入命令行界面。

# docker save b8d391717ee1 > mariadb_images.tar

docker export 66498efd6bd8 > mariadb_images.tar

(4)删除

在server节点将修改的mariadb镜像删除,删除完成后查询镜像列表,将以上操作命令及检查结果填入命令行界面。

# docker rmi -f b8d391717ee1

Untagged: mariadb_new:latest

Deleted: sha256:b8d391717ee14a5f83278a91d9e218a45888a57de113ac92dc91409b108b4aa7

Deleted: sha256:2a4fa9bd49115636b7403e53e5dad740149f9fb2d6761aa196542e76bdd9cd60

# docker images

REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE

rancher/server                       v1.1.4-xd           b4a59c6feee8        3 weeks ago         917.7 MB

192.168.200.12:5000/mariadb               latest              66498efd6bd8        4 months ago        389.9 MB

192.168.200.12:5000/busybox               latest              e02e811dd08f        5 months ago        1.093 MB

192.168.200.12:5000/rancher/agent         v1.0.2              deb5c6987c83        9 months ago        454.3 MB

(5)导入

在server节点将导出的修改的mariadb_images.tar文件导入,命名为mairadb_xiandian:latest,完成后查询镜像列表,将以上操作命令及检查结果填入命令行界面。

# docker load < mariadb_images.tar

# docker tag b8d391717ee1 mairadb_xiandian:latest

# docker images

REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE

mairadb_xiandian                     latest              b8d391717ee1        14 minutes ago      389.9 MB

3.容器

(1)运行

在server节点运行mariadb容器,指定mysql密码为000000,容器运行在后台,使用随机映射端口,容器运行完成后查询容器列表,将以上操作命令及检查结果填入命令行界面。

# docker run -d -P -e MYSQL_ROOT_PASSWORD=000000 192.168.200.12:5000/mariadb:latest

# docker ps -a

CONTAINER ID        IMAGE                           COMMAND                  CREATED              STATUS                  PORTS                            NAMES

a39b8f32b18e        192.168.200.12:5000/mariadb:latest   "docker-entrypoint.sh"   About a minute ago   Up About a minute       0.0.0.0:32846->3306/tcp          romantic_rosalind

(2)开启\停止\重启

在server节点,将运行的mariadb容器停止,完成后查询容器状态,将以上操作命令及检查结果填入命令行界面。

# docker stop a39b8f32b18e

# docker ps -a

CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS                     PORTS                            NAMES

a39b8f32b18e        192.168.200.12:5000/mariadb:latest   "docker-entrypoint.sh"   7 minutes ago       Exited (0) 5 minutes ago                                    romantic_rosalind

在server节点,将运行的mariadb容器开机,完成后查询容器状态,将以上操作命令及检查结果填入命令行界面。

# docker start a39b8f32b18e

# docker ps -a

CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS                  PORTS                            NAMES

a39b8f32b18e        192.168.200.12:5000/mariadb:latest   "docker-entrypoint.sh"   9 minutes ago       Up 18 seconds           0.0.0.0:32848->3306/tcp          romantic_rosalind

在server节点,将运行的mariadb容器重启,将以上操作命令及检查结果填入命令行界面。

# docker restart a39b8f32b18e

(3)attach\exec 连接

在server节点,执行一条命令使用exec获取的rancher/server容器正在运行的网络套接字连接情况,将以上操作命令及检查结果填入命令行界面。

# docker exec 4bffd6c930b5 netstat  -ntpl    

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      -              

tcp6       0      0 :::8080                 :::*                    LISTEN      142/websocket-proxy

tcp6       0      0 :::8081                 :::*                    LISTEN      8/java         

tcp6       0      0 :::8088                 :::*                    LISTEN      149/rancher-catalog

(4)inspect查看底层信息

在server节点,使用inspect只查询rancher/server容器的NetworkSettings内Networks网桥信息,将以上操作命令及检查结果填入命令行界面。

# docker inspect -f {{.NetworkSettings.Networks.bridge}}  4bffd6c930b5

{ [] [] f1924f1024065fa5a634c1ca5583e4231445b3b4e8dd7d790ea6f964f27ff515 71c7903c240bbb8ea835e4773a265ec507b557b1ee1733cff99daae43259cec1 172.17.0.1 172.17.0.2 16   0 02:42:ac:11:00:02}

在server节点,使用inspect只查询rancher/server容器的PortBindings

网桥信息,将以上操作命令及检查结果填入命令行界面。

# docker inspect -f '{{.HostConfig.PortBindings}}' 4bffd6c930b5

map[8080/tcp:[{ 80}]]

在server节点,使用inspect只查询rancher/server容器的NetworkSettings内Ports信息,将以上操作命令及检查结果填入命令行界面。

# docker inspect -f '{{.NetworkSettings.Ports}}'  4bffd6c930b5

map[3306/tcp:[] 8080/tcp:[{0.0.0.0 80}]]

在server节点,使用inspect只查询rancher/server镜像的Tags信息,将以上操作命令及检查结果填入命令行界面。

# docker inspect -f '{{.RepoTags}}' b4a59c6feee8

[rancher/server:v1.1.4-xd]

在server节点,使用inspect只查询rancher/server镜像的Volumes卷组信息,将以上操作命令及检查结果填入命令行界面。

# docker inspect -f '{{.ContainerConfig.Volumes}}' b4a59c6feee8       

map[/var/lib/cattle:{} /var/lib/mysql:{} /var/log/mysql:{}]

在server节点,使用inspect只查询rancher/server镜像的Config信息,将以上操作命令及检查结果填入命令行界面。

# docker inspect -f '{{.Config}}' b4a59c6feee8                 

{   false false false map[3306/tcp:{} 8080/tcp:{}]  false false false [DEFAULT_CATTLE_CATALOG_URL=library=/opt/temp/library,community=/opt/temp/community PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBIAN_FRONTEND=noninteractive CATTLE_HOME=/var/lib/cattle DEFAULT_CATTLE_API_UI_INDEX=//localhost/openstack/1.1.14 CATTLE_DB_CATTLE_DATABASE=mysql CATTLE_USE_LOCAL_ARTIFACTS=true no_proxy=localhost,127.0.0.1,localaddress,.localdomain.com S6_SERVICE_DIR=/service CATTLE_HOST_API_PROXY_MODE=embedded CATTLE_RANCHER_SERVER_VERSION=v1.1.4 CATTLE_RANCHER_COMPOSE_VERSION=v0.8.6 DEFAULT_CATTLE_RANCHER_COMPOSE_LINUX_URL=http://localhost/openstack/rancher-compose-linux-amd64-v0.8.6.tar.gz DEFAULT_CATTLE_RANCHER_COMPOSE_DARWIN_URL=http://localhost/openstack/rancher-compose-darwin-amd64-v0.8.6.tar.gz DEFAULT_CATTLE_RANCHER_COMPOSE_WINDOWS_URL=http://localhost/openstack/rancher-compose-windows-386-v0.8.6.zip CATTLE_CATTLE_VERSION=v0.165.8.4 DEFAULT_CATTLE_MACHINE_EXECUTE=true DEFAULT_CATTLE_COMPOSE_EXECUTOR_EXECUTE=true DEFAULT_CATTLE_CATALOG_EXECUTE=true CATTLE_RANCHER_SERVER_IMAGE=rancher/server] 0xc8205d2020 false  map[/var/log/mysql:{} /var/lib/cattle:{} /var/lib/mysql:{}]  false  [] map[] }

(5)查看容器信息

在server节点,使用inspect只查询rancher/server镜像的Config信息,将以上操作命令及检查结果填入命令行界面。

# docker inspect  4bffd6c930b5

[

    {

        "Id": "4bffd6c930b55421417b62b1080c875cd37d61483cd2e466c66d2039a34cd0aa",

        "Created": "2017-03-13T08:48:23.540651805Z",

        "Path": "/usr/bin/s6-svscan",

        "Args": [

            "/service"

        ],

        "State": {

            "Status": "running",

            "Running": true,

            "Paused": false,

            "Restarting": false,

            "OOMKilled": false,

            "Dead": false,

            "Pid": 21310,

            "ExitCode": 0,

            "Error": "",

            "StartedAt": "2017-03-21T00:37:20.035057426Z",

            "FinishedAt": "2017-03-21T00:37:15.63211683Z"

        },

        "Image": "sha256:b4a59c6feee86e8346a593522553dc4a528f63e5b6206f83106b6079bd3a878b",

        "ResolvConfPath": "/var/lib/docker/containers/4bffd6c930b55421417b62b1080c875cd37d61483cd2e466c66d2039a34cd0aa/resolv.conf",

        "HostnamePath": "/var/lib/docker/containers/4bffd6c930b55421417b62b1080c875cd37d61483cd2e466c66d2039a34cd0aa/hostname",

        "HostsPath": "/var/lib/docker/containers/4bffd6c930b55421417b62b1080c875cd37d61483cd2e466c66d2039a34cd0aa/hosts",

        "LogPath": "",

        "Name": "/server",

        "RestartCount": 0,

        "Driver": "devicemapper",

        "MountLabel": "",

        "ProcessLabel": "",

        "AppArmorProfile": "",

        "ExecIDs": null,

        "HostConfig": {

            "Binds": null,

            "ContainerIDFile": "",

            "LogConfig": {

                "Type": "journald",

                "Config": {}

            },

            "NetworkMode": "default",

            "PortBindings": {

                "8080/tcp": [

                    {

                        "HostIp": "",

                        "HostPort": "80"

                    }

                ]

            },

            "RestartPolicy": {

                "Name": "always",

                "MaximumRetryCount": 0

            },

            "VolumeDriver": "",

            "VolumesFrom": null,

            "CapAdd": null,

            "CapDrop": null,

            "Dns": [],

            "DnsOptions": [],

            "DnsSearch": [],

            "ExtraHosts": null,

            "GroupAdd": null,

            "IpcMode": "",

            "Links": null,

            "OomScoreAdj": 0,

            "PidMode": "",

            "Privileged": false,

            "PublishAllPorts": false,

            "ReadonlyRootfs": false,

            "SecurityOpt": null,

            "UTSMode": "",

            "ShmSize": 67108864,

            "ConsoleSize": [

                0,

                0

            ],

            "Isolation": "",

            "CpuShares": 0,

            "CgroupParent": "",

            "BlkioWeight": 0,

            "BlkioWeightDevice": null,

            "BlkioDeviceReadBps": null,

            "BlkioDeviceWriteBps": null,

            "BlkioDeviceReadIOps": null,

            "BlkioDeviceWriteIOps": null,

            "CpuPeriod": 0,

            "CpuQuota": 0,

            "CpusetCpus": "",

            "CpusetMems": "",

            "Devices": [],

            "KernelMemory": 0,

            "Memory": 0,

            "MemoryReservation": 0,

            "MemorySwap": 0,

            "MemorySwappiness": -1,

            "OomKillDisable": false,

            "PidsLimit": 0,

            "Ulimits": null

        },

        "GraphDriver": {

            "Name": "devicemapper",

            "Data": {

                "DeviceId": "77",

                "DeviceName": "docker-253:1-268435649-47f91f74bac39216084496792f44d056dd95fc49f8a64115452621c24e2eff4b",

                "DeviceSize": "10737418240"

            }

        },

        "Mounts": [

            {

                "Name": "a4d71a18abf39258d66bd22e444d0b3740b1d09284035f0987d6faf4ee78ec17",

                "Source": "/var/lib/docker/volumes/a4d71a18abf39258d66bd22e444d0b3740b1d09284035f0987d6faf4ee78ec17/_data",

                "Destination": "/var/lib/cattle",

                "Driver": "local",

                "Mode": "",

                "RW": true,

                "Propagation": ""

            },

            {

                "Name": "9a7e86fc8a647367492b54e94dc8290ae722c5b6a3cf311869b82d907863151d",

                "Source": "/var/lib/docker/volumes/9a7e86fc8a647367492b54e94dc8290ae722c5b6a3cf311869b82d907863151d/_data",

                "Destination": "/var/lib/mysql",

                "Driver": "local",

                "Mode": "",

                "RW": true,

                "Propagation": ""

            },

            {

                "Name": "adf794bc62dd8102a3018bf15034db6b52474d5e4935177ed73ab9b0a5d73630",

                "Source": "/var/lib/docker/volumes/adf794bc62dd8102a3018bf15034db6b52474d5e4935177ed73ab9b0a5d73630/_data",

                "Destination": "/var/log/mysql",

                "Driver": "local",

                "Mode": "",

                "RW": true,

                "Propagation": ""

            }

        ],

        "Config": {

            "Hostname": "4bffd6c930b5",

            "Domainname": "",

            "User": "",

            "AttachStdin": false,

            "AttachStdout": false,

            "AttachStderr": false,

            "ExposedPorts": {

                "3306/tcp": {},

                "8080/tcp": {}

            },

            "Tty": false,

            "OpenStdin": false,

            "StdinOnce": false,

            "Env": [

                "DEFAULT_CATTLE_CATALOG_URL=library=/opt/temp/library,community=/opt/temp/community",

                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",

                "DEBIAN_FRONTEND=noninteractive",

                "CATTLE_HOME=/var/lib/cattle",

                "DEFAULT_CATTLE_API_UI_INDEX=//localhost/openstack/1.1.14",

                "CATTLE_DB_CATTLE_DATABASE=mysql",

                "CATTLE_USE_LOCAL_ARTIFACTS=true",

                "no_proxy=localhost,127.0.0.1,localaddress,.localdomain.com",

                "S6_SERVICE_DIR=/service",

                "CATTLE_HOST_API_PROXY_MODE=embedded",

                "CATTLE_RANCHER_SERVER_VERSION=v1.1.4",

                "CATTLE_RANCHER_COMPOSE_VERSION=v0.8.6",

                "DEFAULT_CATTLE_RANCHER_COMPOSE_LINUX_URL=http://localhost/openstack/rancher-compose-linux-amd64-v0.8.6.tar.gz",

                "DEFAULT_CATTLE_RANCHER_COMPOSE_DARWIN_URL=http://localhost/openstack/rancher-compose-darwin-amd64-v0.8.6.tar.gz",

                "DEFAULT_CATTLE_RANCHER_COMPOSE_WINDOWS_URL=http://localhost/openstack/rancher-compose-windows-386-v0.8.6.zip",

                "CATTLE_CATTLE_VERSION=v0.165.8.4",

                "DEFAULT_CATTLE_MACHINE_EXECUTE=true",

                "DEFAULT_CATTLE_COMPOSE_EXECUTOR_EXECUTE=true",

                "DEFAULT_CATTLE_CATALOG_EXECUTE=true",

                "CATTLE_RANCHER_SERVER_IMAGE=rancher/server"

            ],

            "Cmd": [

                "/usr/bin/s6-svscan",

                "/service"

            ],

            "Image": "rancher/server:v1.1.4-xd",

            "Volumes": {

                "/var/lib/cattle": {},

                "/var/lib/mysql": {},

                "/var/log/mysql": {}

            },

            "WorkingDir": "",

            "Entrypoint": null,

            "OnBuild": null,

            "Labels": {}

        },

        "NetworkSettings": {

            "Bridge": "",

            "SandboxID": "a4d38d0d3ba0c3d7c8ea5c9a6eb2e28bc31ec0a87a44b93acaf16c8014a997ca",

            "HairpinMode": false,

            "LinkLocalIPv6Address": "",

            "LinkLocalIPv6PrefixLen": 0,

            "Ports": {

                "3306/tcp": null,

                "8080/tcp": [

                    {

                        "HostIp": "0.0.0.0",

                        "HostPort": "80"

                    }

                ]

            },

            "SandboxKey": "/var/run/docker/netns/a4d38d0d3ba0",

            "SecondaryIPAddresses": null,

            "SecondaryIPv6Addresses": null,

            "EndpointID": "71c7903c240bbb8ea835e4773a265ec507b557b1ee1733cff99daae43259cec1",

            "Gateway": "172.17.0.1",

            "GlobalIPv6Address": "",

            "GlobalIPv6PrefixLen": 0,

            "IPAddress": "172.17.0.2",

            "IPPrefixLen": 16,

            "IPv6Gateway": "",

            "MacAddress": "02:42:ac:11:00:02",

            "Networks": {

                "bridge": {

                    "IPAMConfig": null,

                    "Links": null,

                    "Aliases": null,

                    "NetworkID": "f1924f1024065fa5a634c1ca5583e4231445b3b4e8dd7d790ea6f964f27ff515",

                    "EndpointID": "71c7903c240bbb8ea835e4773a265ec507b557b1ee1733cff99daae43259cec1",

                    "Gateway": "172.17.0.1",

                    "IPAddress": "172.17.0.2",

                    "IPPrefixLen": 16,

                    "IPv6Gateway": "",

                    "GlobalIPv6Address": "",

                    "GlobalIPv6PrefixLen": 0,

                    "MacAddress": "02:42:ac:11:00:02"

                }

            }

        }

    }

]

(6)简单操作

在server节点,使用docker命令查询rancher/server镜像的进程,将以上操作命令及检查结果填入命令行界面。

# docker top  4bffd6c930b5       

UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD

root                19572               21323               0                   00:42               ?                   00:00:09            go-machine-service

root                19585               21323               0                   00:42               ?                   00:00:18            rancher-compose-executor

root                21310               21234               0                   Mar21               ?                   00:00:07            /usr/bin/s6-svscan /service

root                21319               21310               0                   Mar21               ?                   00:00:00            s6-supervise cattle

root                21320               21310               0                   Mar21               ?                   00:00:00            s6-supervise mysql

root                21323               21319               0                   Mar21               ?                   00:55:27            java -Xms128m -Xmx2g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/lib/cattle/logs -Dlogback.bootstrap.level=WARN -cp /usr/share/cattle/58488b81592773dcae114770406e3e1b:/usr/share/cattle/58488b81592773dcae114770406e3e1b/etc/cattle io.cattle.platform.launcher.Main

102                 21342               21320               0                   Mar21               ?                   00:15:04            /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306

root                21465               21323               0                   Mar21               ?                   00:10:32            websocket-proxy

root                21472               21323               0                   Mar21               ?                   00:01:22            rancher-catalog-service -catalogUrl library=/opt/temp/library,community=/opt/temp/community -refreshInterval 300

在server节点,使用docker命令查列出容器内发生变化的文件和目录,将以上操作命令及检查结果填入命令行界面。

# docker diff   4bffd6c930b5

C /run

C /run/mysqld

C /run/mysqld/mysqld.pid

C /run/mysqld/mysqld.sock

C /service

C /service/cattle

C /service/cattle/supervise

C /service/cattle/supervise/status

C /service/mysql

C /service/mysql/supervise

C /service/mysql/supervise/status

C /service/mysql/supervise/control

C /usr

C /usr/local

C /usr/local/bin

A /usr/local/bin/docker-machine-driver-packet

C /root

C /root/.bash_history

C /etc

C /etc/mysql

C /etc/mysql/my.cnf

C /tmp

C /tmp/hsperfdata_root

C /tmp/hsperfdata_root/8

A /tmp/jetty-0.0.0.0-8081-58488b81592773dcae114770406e3e1b-_-any-2649025364052028092.dir

在server节点,使用docker命令打印指定时间内的容器的实时系统事件,将以上操作命令及检查结果填入命令行界面。

# docker    events

C /run

C /run/mysqld

C /run/mysqld/mysqld.pid

C /run/mysqld/mysqld.sock

C /service

C /service/cattle

C /service/cattle/supervise

C /service/cattle/supervise/status

C /service/mysql

C /service/mysql/supervise

C /service/mysql/supervise/status

C /service/mysql/supervise/control

C /usr

C /usr/local

C /usr/local/bin

A /usr/local/bin/docker-machine-driver-packet

C /root

C /root/.bash_history

C /etc

C /etc/mysql

C /etc/mysql/my.cnf

C /tmp

C /tmp/hsperfdata_root

C /tmp/hsperfdata_root/8

A /tmp/jetty-0.0.0.0-8081-58488b81592773dcae114770406e3e1b-_-any-2649025364052028092.dir

在server节点,使用docker命令查看最后退出的容器的ID,将以上操作命令及检查结果填入命令行界面。

[root@registry ~]# docker ps -l

CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS                      PORTS               NAMES

72ad2719b721        192.168.200.12:5000/taicai/java_web:v1.0   "/bin/sh -c '${CATALI"   22 hours ago        Exited (143) 19 hours ago                       berserk_wright

(7)打包\拷贝\删除

在server节点将运行的mariadb容器保存为mariadb.tar文件,将以上操作命令及检查结果填入命令行界面。

# docker export 8998a53f34da  > mariadb.tar

在server节点将运行的mariadb容器创建为镜像名为mariadb_new:latest,完成后查询镜像列表,将以上操作命令及检查结果填入命令行界面。

# docker commit 8998a53f34da mariadb_new:latest

# docker images

REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE

mariadb_new                          latest              b8d391717ee1        6 seconds ago       389.9 MB

在server节点删除正在运行的mariadb容器,完成后查询容器列表,将以上操作命令及检查结果填入命令行界面。

# docker rm -f 8998a53f34da

# docker ps -a

be3cefcbf7f3        192.168.200.12:5000/taicai/nginx:v1.0            "/bin/sh -c /usr/sbin"   3 days ago          Exited (0) About an hour ago                              jolly_elion

940568599bb2        192.168.200.12:5000/registry:latest              "/entrypoint.sh /etc/"   6 weeks ago         Up About an hour                 0.0.0.0:5000->5000/tcp   registry

在registry节点查询registry容器的CPU、内存等统计信息,将以上操作命令及检查结果填入命令行界面。

# docker stats 940568599bb2

CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O

940568599bb2        0.00%               155.4 MB / 2.099 GB   7.40%               276.5 kB / 131.5 MB   151.8 MB / 0 B

在registry节点查所有容器的CPU、内存等统计信息,将以上操作命令及检查结果填入命令行界面。

# docker stats –a

CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O

28c212378a55        0.00%               0 B / 0 B             0.00%               0 B / 0 B             0 B / 0 B

6cef0055e66d        0.00%               0 B / 0 B             0.00%               0 B / 0 B             0 B / 0 B

72ad2719b721        0.00%               0 B / 0 B             0.00%               0 B / 0 B             0 B / 0 B

940568599bb2        0.00%               155.4 MB / 2.099 GB   7.40%               276.5 kB / 131.5 MB   151.8 MB / 0 B

be3cefcbf7f3        0.00%               0 B / 0 B             0.00%               0 B / 0 B             0 B / 0 B

在server节点修改运行的rancher/server容器的名称,修改名称为xiandian_server,完成后查询容器列表,将以上操作命令及检查结果填入命令行界面。

# docker rename 4bffd6c930b5 xiandian_ server

# docker ps -a

4bffd6c930b5        rancher/server:v1.1.4-xd        "/usr/bin/s6-svscan /"   2 weeks ago         Up 12 minutes           3306/tcp, 0.0.0.0:80->8080/tcp   xiandian_ server

(8)其他

在server节点,使用docker命令列举所有的网络,将以上操作命令及检查结果填入命令行界面。

# docker network  ls

NETWORK ID          NAME                DRIVER

98f6f49a08a9        host                host               

f1924f102406        bridge              bridge             

f4b61dd01d6d        none                null        

在server节点,使用docker命令查询bridge网络的所有详情,将以上操作命令及检查结果填入命令行界面。

# docker network inspect bridge

[

    {

        "Name": "bridge",

        "Id": "f1924f1024065fa5a634c1ca5583e4231445b3b4e8dd7d790ea6f964f27ff515",

        "Scope": "local",

        "Driver": "bridge",

        "IPAM": {

            "Driver": "default",

            "Options": null,

            "Config": [

                {

                    "Subnet": "172.17.0.0/16",

                    "Gateway": "172.17.0.1"

                }

            ]

        },

        "Containers": {

            "0096f7587e08a22d44882c770623ea711cacbd2fa967632065f583d79f44a65f": {

                "Name": "determined_bose",

                "EndpointID": "9bb37919a2c403c8c6c76589ec254204f2f8ae16e59ed3b34ab179da4fdf58cc",

                "MacAddress": "02:42:ac:11:00:3f",

                "IPv4Address": "172.17.0.63/16",

                "IPv6Address": ""

            },

            "012dea2bb42cf71f35fe71699a0d140558fd3f9dc73e7f2fc757c36edf220763": {

                "Name": "compassionate_lalande",

                "EndpointID": "192ca1a63dc0153cb8b86f3a801c275a0a83b60a1fbdf8651d05384713903930",

                "MacAddress": "02:42:ac:11:00:37",

                "IPv4Address": "172.17.0.55/16",

                "IPv6Address": ""

            },

        },

        "Options": {

            "com.docker.network.bridge.default_bridge": "true",

            "com.docker.network.bridge.enable_icc": "true",

            "com.docker.network.bridge.enable_ip_masquerade": "true",

            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",

            "com.docker.network.bridge.name": "docker0",

            "com.docker.network.driver.mtu": "1500"

        }

    }

]

在server节点,使用docker命令创建名为xd_net的网络,网络网段为192.168.3.0/24,网关为192.168.3.1,创建完成后查询网络列表,将以上操作命令及检查结果填入命令行界面。

# docker network create --subnet=192.168.3.0/24 --ip-range=192.168.3.0/24 --gateway=192.168.3.1   xd_net

# docker network ls

NETWORK ID          NAME                DRIVER

98f6f49a08a9        host                host               

ffa150e53889        xd_net              bridge             

f1924f102406        bridge              bridge             

f4b61dd01d6d        none                null

在server节点,使用docker命令创建名为xd_net的网络,网络网段为192.168.3.0/24,网关为192.168.3.1,创建完成后查询此网络的详细信息,将以上操作命令及检查结果填入命令行界面。

# docker network create --subnet=192.168.3.0/24 --ip-range=192.168.3.0/24 --gateway=192.168.3.1   xd_net

# docker network inspect xd_net

[

    {

        "Name": "xd_net",

        "Id": "ffa150e538894f9c2a4e8e9a53f716a5a8ad86ea1b61aff3f9971e48c1e25588",

        "Scope": "local",

        "Driver": "bridge",

        "IPAM": {

            "Driver": "default",

            "Options": {},

            "Config": [

                {

                    "Subnet": "192.168.3.0/24",

                    "IPRange": "192.168.3.0/24",

                    "Gateway": "192.168.3.1"

                }

            ]

        },

        "Containers": {},

        "Options": {}

    }

]

在server节点,创建镜像为ubuntu,容器名称为ubuntu,使用docker网络为xd_net,创建完成后查询容器使用的网络名称和查询该容器的运行状态,将以上操作命令及检查结果填入命令行界面。

# docker run -ditP --net=xd_net --name ubuntu ubuntu:14.04.3

# docker inspect -f '{{.NetworkSettings.Networks}}' ubuntu

map[xd_net:0xc8200ba0c0]

# docker ps -a

CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                            NAMES

35058aa35fa5        ubuntu:14.04.3             "/bin/bash"              2 minutes ago       Up 2 minutes                                         ubuntu

在server节点,创建镜像为ubuntu,容器名称为ubuntu,使用docker网络为xd_net,创建完成后查询容器IP地址和查询该容器的运行状态,将以上操作命令及检查结果填入命令行界面。

# docker run -ditP --net=xd_net --name ubuntu ubuntu:14.04.3

docker inspect -f '{{.NetworkSettings.Networks.xd_net.IPAddress}}' ubuntu

192.168.3.2

# docker ps -a

CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                            NAMES

35058aa35fa5        ubuntu:14.04.3             "/bin/bash"              2 minutes ago       Up 2 minutes                                         ubuntu

在server节点,删除docker网络xd_net,完成后查询docker网络列表,将以上操作命令及检查结果填入命令行界面。

# docker network rm xd_net

# docker network ls

NETWORK ID          NAME                DRIVER

f4b61dd01d6d        none                null               

98f6f49a08a9        host                host               

f1924f102406        bridge              bridge  

在server节点,使用docker命令只列举rancher/server容器的端口映射状态,将以上操作命令及检查结果填入命令行界面。

# docker port 4bffd6c930b5

8080/tcp -> 0.0.0.0:80

在server节点,使用docker命令打印rancher/server镜像的大小和日期历史更新信息。将以上操作命令及检查结果填入命令行界面。

# docker history -H rancher/server:v1.1.4-xd 

IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT

b4a59c6feee8        3 weeks ago         /usr/bin/s6-svscan /service                     53.64 kB           

           3 weeks ago         /usr/bin/s6-svscan /service                     3.776 MB           

           3 weeks ago         /usr/bin/s6-svscan /service                     3.221 MB           

           3 weeks ago         /usr/bin/s6-svscan /service                     716.1 kB           

           3 weeks ago         /usr/bin/s6-svscan /service                     36.79 kB           

           4 weeks ago         /usr/bin/s6-svscan /service                     70.29 kB           

           4 weeks ago         /usr/bin/s6-svscan /service                     36.6 kB            

           4 weeks ago         /bin/sh -c #(nop)  CMD ["/usr/bin/s6-svscan"    0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV CATTLE_RANCHER_SERVER_   0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV DEFAULT_CATTLE_CATALOG   0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV DEFAULT_CATTLE_COMPOSE   0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV DEFAULT_CATTLE_MACHINE   0 B                

           4 weeks ago         /bin/sh -c #(nop)  VOLUME [/var/lib/mysql /va   0 B                

           4 weeks ago         /bin/sh -c for i in $DEFAULT_CATTLE_CATALOG_U   997.5 kB           

          4 weeks ago         /bin/sh -c #(nop) COPY file:b14ee9c6198b8ebc9   13.62 MB           

           4 weeks ago         /bin/sh -c #(nop) COPY file:8c4d85a8afd9ff91f   13.62 MB           

           4 weeks ago         /bin/sh -c #(nop) COPY file:61a0875be62ec5386   38.51 MB           

           4 weeks ago         /bin/sh -c #(nop) COPY file:8daaff4a6b942739b   0 B                

           4 weeks ago         /bin/sh -c #(nop) COPY file:659a2ee532a77ef03   0 B                

           4 weeks ago         /bin/sh -c #(nop) COPY file:ea77dfac21014fbee   0 B                

           4 weeks ago         /bin/sh -c cd $CATTLE_HOME && export IFS=","    0 B                

           4 weeks ago         /bin/sh -c /opt/install_cattle_binaries         163.3 MB           

           4 weeks ago         /bin/sh -c #(nop) COPY file:69a7f5663566287b1   1.456 kB           

           4 weeks ago         /bin/sh -c tar xvzf /root/1.1.14.tar.gz  -C /   27.4 MB            

           4 weeks ago         /bin/sh -c /usr/share/cattle/cattle.sh extrac   106.1 MB           

           4 weeks ago         /bin/sh -c mkdir -p $CATTLE_HOME                0 B                

           4 weeks ago         /bin/sh -c rm -rf /s6-statics/*static.tar.gz    0 B                

           4 weeks ago         /bin/sh -c cd / && for i in $(ls /s6-statics/   4.289 MB           

           4 weeks ago         /bin/sh -c #(nop) ADD tarsum.v1+sha256:37ff07   12.35 MB           

           4 weeks ago         /bin/sh -c #(nop)  ENV CATTLE_CATTLE_VERSION=   0 B                

           4 weeks ago         /bin/sh -c #(nop)  EXPOSE 3306/tcp              0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV DEFAULT_CATTLE_CATALOG   0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV DEFAULT_CATTLE_RANCHER   0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV DEFAULT_CATTLE_RANCHER   0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV DEFAULT_CATTLE_RANCHER   0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV CATTLE_RANCHER_COMPOSE   0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV CATTLE_RANCHER_SERVER_   0 B                

           4 weeks ago         /bin/sh -c #(nop)  ENV CATTLE_HOST_API_PROXY_   0 B                

           4 weeks ago         /bin/sh -c #(nop)  EXPOSE 8080/tcp              0 B                

           4 weeks ago         /bin/sh -c #(nop) COPY multi:c4e33239823be219   1.569 MB           

           4 weeks ago         /bin/sh -c #(nop)  ENV S6_SERVICE_DIR=/servic   0 B                

           4 weeks ago         /bin/sh -c #(nop) ADD dir:e460a162de3ab187d80   420 B              

           4 weeks ago         /bin/sh -c #(nop) COPY file:a91fbc37bceb3dd4f   4.568 kB           

           4 weeks ago         /bin/sh -c #(nop) COPY file:8fac002511c5eb540   5.084 MB           

           5 weeks ago         /bin/sh -c #(nop) ADD dir:da6ea441cc92b1730ac   252.8 kB           

           5 weeks ago         /bin/sh -c #(nop)  ENV no_proxy=localhost,127   0 B                

           5 weeks ago         /bin/sh -c #(nop)  ENV CATTLE_USE_LOCAL_ARTIF   0 B                 

           5 weeks ago         /bin/sh -c #(nop)  ENV CATTLE_DB_CATTLE_DATAB   0 B                

           5 weeks ago         /bin/sh -c #(nop)  ENV DEFAULT_CATTLE_API_UI_   0 B                

           5 weeks ago         /bin/sh -c #(nop)  ENV CATTLE_HOME=/var/lib/c   0 B                

           5 weeks ago         /bin/sh -c #(nop) COPY multi:ae0933d1936489aa   4.206 kB           

           5 weeks ago         /bin/sh -c chmod +x /usr/bin/giddyup /usr/bin   20.78 MB           

           5 weeks ago         /bin/sh -c #(nop) ADD tarsum.v1+sha256:f6f649   14.44 MB           

           5 weeks ago         /bin/sh -c #(nop) ADD tarsum.v1+sha256:65604f   6.343 MB           

           5 weeks ago         /bin/sh -c apt-get update && apt-get install    293.1 MB           

           5 weeks ago         /bin/sh -c #(nop)  ENV DEBIAN_FRONTEND=nonint   0 B                

           8 months ago        /bin/sh -c #(nop) CMD ["/bin/bash"]             0 B                

           8 months ago        /bin/sh -c sed -i 's/^#\s*\(deb.*universe\)$/   1.895 kB           

           8 months ago        /bin/sh -c rm -rf /var/lib/apt/lists/*          0 B                

           8 months ago        /bin/sh -c set -xe   && echo '#!/bin/sh' > /u   194.6 kB           

           8 months ago        /bin/sh -c #(nop) ADD file:dc3b1b2c44af75026b   187.7 MB 

在server节点,使用docker命令运行ubuntu镜像,运行输出打印“Hello world”,将以上操作命令及检查结果填入命令行界面。

# docker run ubuntu:14.04.3  /bin/echo "Hello world"

Hello world

在server节点,使用docker命令运行ubuntu镜像,运行输出打印“Hello world”,要求启动命令包含打印完成后自动删除此容器及产生的数据。将以上操作命令及检查结果填入命令行界面。

# docker run --rm ubuntu:14.04.3  /bin/echo "Hello world"

Hello world

在server节点,使用docker命令查询2017-03-01至2017-03-02之间的所有时间记录。将以上操作命令及检查结果填入命令行界面。

# docker events  --since="2017-03-01" --until="2017-03-01"

2017-03-28T02:15:16.056464309Z network disconnect f1924f1024065fa5a634c1ca5583e4231445b3b4e8dd7d790ea6f964f27ff515 (container=f851747fd59dd907a76d11e643287d4ae0033537ccf14b186adf8e829004cc73, name=bridge, type=bridge)

2017-03-28T02:15:18.254105469Z container destroy f851747fd59dd907a76d11e643287d4ae0033537ccf14b186adf8e829004cc73 (image=xd-centos6.5-ssh, name=high_bassi, License=GPLv2, Vendor=CentOS)

2017-03-28T02:15:18.255150999Z container kill 1b872e423e4e314abc75b3ac578b607cb538b433ee9b5d08bcd89542819caa4b (License=GPLv2, Vendor=CentOS, image=xd-centos6.5-ssh, name=gigantic_shirley)

2017-03-28T02:15:18.277789480Z container die 1b872e423e4e314abc75b3ac578b607cb538b433ee9b5d08bcd89542819caa4b (License=GPLv2, Vendor=CentOS, image=xd-centos6.5-ssh, name=gigantic_shirley)

2017-03-28T02:15:19.004695174Z network disconnect f1924f1024065fa5a634c1ca5583e4231445b3b4e8dd7d790ea6f964f27ff515 (container=1b872e423e4e314abc75b3ac578b607cb538b433ee9b5d08bcd89542819caa4b, name=bridge, type=bridge)

2017-03-28T02:15:22.351027094Z container destroy 1b872e423e4e314abc75b3ac578b607cb538b433ee9b5d08bcd89542819caa4b (image=xd-centos6.5-ssh, name=gigantic_shirley, License=GPLv2, Vendor=CentOS)

2017-03-28T02:15:22.352106069Z container kill 6aba1efbaff9b712c08466eaf790de32c24df6e151e11c508976027e500d1e4f (Vendor=CentOS, image=xd-centos6.5-ssh, name=loving_snyder, License=GPLv2)

2017-03-28T02:15:22.374417791Z container die 6aba1efbaff9b712c08466eaf790de32c24df6e151e11c508976027e500d1e4f (name=loving_snyder, License=GPLv2, Vendor=CentOS, image=xd-centos6.5-ssh)

2017-03-28T02:15:22.558057748Z network disconnect f1924f1024065fa5a634c1ca5583e4231445b3b4e8dd7d790ea6f964f27ff515 (type=bridge, container=6aba1efbaff9b712c08466eaf790de32c24df6e151e11c508976027e500d1e4f, name=bridge)

2017-03-28T02:15:24.177540060Z container destroy 6aba1efbaff9b712c08466eaf790de32c24df6e151e11c508976027e500d1e4f (License=GPLv2, Vendor=CentOS, image=xd-centos6.5-ssh, name=loving_snyder)

2017-03-28T02:15:24.178570068Z container kill d332d4d77849503464d30ac6a2b8b121d94a1fc94e57e305386f4ac8cd6ea419 (License=GPLv2, Vendor=CentOS, image=xd-centos6.5-ssh, name=modest_pike)

2017-03-28T02:15:24.200395874Z container die d332d4d77849503464d30ac6a2b8b121d94a1fc94e57e305386f4ac8cd6ea419 (License=GPLv2, Vendor=CentOS, image=xd-centos6.5-ssh, name=modest_pike)

2017-03-28T02:15:24.420600287Z network disconnect f1924f1024065fa5a634c1ca5583e4231445b3b4e8dd7d790ea6f964f27ff515 (container=d332d4d77849503464d30ac6a2b8b121d94a1fc94e57e305386f4ac8cd6ea419, name=bridge, type=bridge)

2017-03-28T02:20:29.519944245Z container die e310a266fc7b6e466832e8389a85cc344fd5f9e570b57870eb653f7c694fc968 (image=ubuntu:14.04.3, name=ubuntu)

2017-03-28T02:20:30.033914440Z network disconnect ffa150e538894f9c2a4e8e9a53f716a5a8ad86ea1b61aff3f9971e48c1e25588 (container=e310a266fc7b6e466832e8389a85cc344fd5f9e570b57870eb653f7c694fc968, name=xd_net, type=bridge)

2017-03-28T02:21:08.322569700Z container destroy e310a266fc7b6e466832e8389a85cc344fd5f9e570b57870eb653f7c694fc968 (image=ubuntu:14.04.3, name=ubuntu)

2017-03-28T02:21:19.206790021Z container create 35058aa35fa5a43e79966f7b640c167ae34467c83532a65b49e8a36a8e401a01 (image=ubuntu:14.04.3, name=ubuntu)

2017-03-28T02:21:19.695610782Z network connect ffa150e538894f9c2a4e8e9a53f716a5a8ad86ea1b61aff3f9971e48c1e25588 (container=35058aa35fa5a43e79966f7b640c167ae34467c83532a65b49e8a36a8e401a01, name=xd_net, type=bridge)

2017-03-28T02:51:54.253349571Z network disconnect f1924f1024065fa5a634c1ca5583e4231445b3b4e8dd7d790ea6f964f27ff515 (type=bridge, container=6eb048e142c2ce276bef8c346fe7b1566fca81e23366057accc6b48c08065f0a, name=bridge)

2017-03-28T02:51:55.813156762Z container destroy 6eb048e142c2ce276bef8c346fe7b1566fca81e23366057accc6b48c08065f0a (image=ubuntu:14.04.3, name=elated_mirzakhani)

在server节点,使用docker命令运行ubuntu镜像,运行输出打印“Hello world”,要求启动命令包含打印完成后自动删除此容器。将以上操作命令及检查结果填入命令行界面。

# docker run --rm ubuntu:14.04.3  /bin/echo "Hello world"

Hello world

在server节点,使用docker命令将rancher/server容器内的/opt/目录下rancher.tar.gz文件拷贝到宿主机的/opt/目录下。完成后查询文件大小,将以上操作命令及检查结果填入命令行界面。

# docker cp 4bffd6c930b5:/opt/rancher.tar.gz .

# du -sh rancher.tar.gz

2.5M    rancher.tar.gz

在server节点,使用docker命令将当前操作系统的yum源repo文件拷贝到rancher/server容器内的/opt/目录下。完成后查询容器的/opt目录下的所有文件列表,并查询文件内容,将以上操作命令及检查结果填入命令行界面。

# docker cp /etc/yum.repos.d/local.repo  4bffd6c930b5:/opt/

# docker exec -it 4bffd6c930b5 /bin/ls /opt/

cattle-global.properties  local.repo      temp

install_cattle_binaries   rancher.tar.gz

# docker exec -it 4bffd6c930b5 /bin/cat  /opt/local.repo

[centos]

name=centos

baseurl=ftp://10.0.0.254/file/cr/2017/centos7.2/

gpgcheck=0

enabled=1

[iaas]

name=iaas

baseurl=ftp://10.0.0.254/file/cr/2017/docker/docker/

gpgcheck=0

enabled=1

在client节点,使用docker命令查询正在实时运行的容器列表,将以上操作命令及检查结果填入命令行界面。

# docker ps

CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                                          NAMES

3949b68a8b6e        rocketchat/hubot-rocketchat:latest   "/bin/sh -c 'node -e "   21 hours ago        Up 21 hours         0.0.0.0:3001->8080/tcp                         07ca61f2-3657-464e-8872-25180ff0c18f

4c55d007c682        rocketchat/rocket.chat:latest        "node main.js"           21 hours ago        Up 20 hours         0.0.0.0:3000->3000/tcp                         963581eb-74cd-4a2a-91ca-e3afbdc884fa

5e1bd01263d5        mongo:latest                         "/entrypoint.sh mongo"   21 hours ago        Up 20 hours         27017/tcp                                      cbf83738-f90a-4030-88bc-170e8f3d7504

e796884b627e        jenkins:1.651.3                      "/usr/share/jenkins/r"   21 hours ago        Up 20 hours         50000/tcp, 0.0.0.0:9095->8080/tcp              f7cc7b20-c2a7-4b6e-9190-b25f474cd42e

f0043c7907b7        rancher/jenkins-plugins:v0.1.1       "/confd --backend ran"   22 hours ago        Up 20 hours                                                        r-jenkins_jenkins-primary_jenkins-plugins_1

a905c0b003fe        opensaas/concrete5:latest            "apache2-foreground"     22 hours ago        Up 21 hours         80/tcp                                         r-Concrete5_Concrete5App_1

bc9825ef1818        mysql:latest                         "docker-entrypoint.sh"   22 hours ago        Up 21 hours         3306/tcp                                       r-Concrete5_CMSMysql_1

bd9f804d9ccc        owncloud:latest                      "/entrypoint.sh apach"   23 hours ago        Up 21 hours         0.0.0.0:80->80/tcp                             r-owncloud_owncloud_1

0a801449b132        wordpress:latest                     "docker-entrypoint.sh"   23 hours ago        Up 20 hours         0.0.0.0:9098->80/tcp                           r-wordpress_wordpress_1

d723cdceb8f0        mariadb:latest                       "docker-entrypoint.sh"   23 hours ago        Up 20 hours         3306/tcp                                       r-wordpress_db_1

286de803b06c        gogs/gogs:latest                     "docker/start.sh /bin"   23 hours ago        Up 21 hours         0.0.0.0:222->22/tcp, 0.0.0.0:9093->3000/tcp    r-gogs_gogs_1

99697671f552        mariadb:latest                       "docker-entrypoint.sh"   24 hours ago        Up 20 hours         3306/tcp                                       r-owncloud_db_1

781376644b98        grafana/grafana:latest               "/run.sh"                24 hours ago        Up 21 hours         0.0.0.0:9094->3000/tcp                         r-grafana_grafana_1

58987ce8c284        mysql:latest                         "docker-entrypoint.sh"   24 hours ago        Up 21 hours         0.0.0.0:3306->3306/tcp                         r-gogs_mysql_1

6fa86a287731        ghost:latest                         "/entrypoint.sh npm s"   24 hours ago        Up 21 hours         0.0.0.0:9092->2368/tcp                         r-ghost_ghost_1

4792a9cc5e26        rancher/agent-instance:v0.8.3        "/etc/init.d/agent-in"   7 days ago          Up 21 hours         0.0.0.0:500->500/udp, 0.0.0.0:4500->4500/udp   227ccb46-72f6-4271-a8e5-3b2ed8a054e2

e9d751dfb08c        rancher/agent:v1.0.2                 "/run.sh run"            2 weeks ago         Up 21 hours                                                        rancher-agent

在client节点,使用docker命令查询所有的容器列表,将以上操作命令及检查结果填入命令行界面。

# docker ps -a

CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS                    PORTS                                          NAMES

3949b68a8b6e        rocketchat/hubot-rocketchat:latest   "/bin/sh -c 'node -e "   21 hours ago        Up 21 hours               0.0.0.0:3001->8080/tcp                         07ca61f2-3657-464e-8872-25180ff0c18f

4c55d007c682        rocketchat/rocket.chat:latest        "node main.js"           21 hours ago        Up 21 hours               0.0.0.0:3000->3000/tcp                         963581eb-74cd-4a2a-91ca-e3afbdc884fa

5e1bd01263d5        mongo:latest                         "/entrypoint.sh mongo"   21 hours ago        Up 21 hours               27017/tcp                                      cbf83738-f90a-4030-88bc-170e8f3d7504

e796884b627e        jenkins:1.651.3                      "/usr/share/jenkins/r"   21 hours ago        Up 20 hours               50000/tcp, 0.0.0.0:9095->8080/tcp              f7cc7b20-c2a7-4b6e-9190-b25f474cd42e

444b56b643c3        opensaas/concrete5:latest            "bash -c 'chown -R ww"   21 hours ago        Exited (1) 20 hours ago                                                  r-Concrete5_Concrete5App_CMSConfig_1

a80c1184ab76        busybox:latest                       "chown -R 1000:1000 /"   21 hours ago        Exited (0) 20 hours ago                                                  r-jenkins_jenkins-primary_jenkins-datavolume_1

f0043c7907b7        rancher/jenkins-plugins:v0.1.1       "/confd --backend ran"   22 hours ago        Up 21 hours                                                              r-jenkins_jenkins-primary_jenkins-plugins_1

a905c0b003fe        opensaas/concrete5:latest            "apache2-foreground"     22 hours ago        Up 21 hours               80/tcp                                         r-Concrete5_Concrete5App_1

bc9825ef1818        mysql:latest                         "docker-entrypoint.sh"   22 hours ago        Up 21 hours               3306/tcp                                       r-Concrete5_CMSMysql_1

bd9f804d9ccc        owncloud:latest                      "/entrypoint.sh apach"   23 hours ago        Up 21 hours               0.0.0.0:80->80/tcp                             r-owncloud_owncloud_1

0a801449b132        wordpress:latest                     "docker-entrypoint.sh"   23 hours ago        Up 21 hours               0.0.0.0:9098->80/tcp                           r-wordpress_wordpress_1

d723cdceb8f0        mariadb:latest                       "docker-entrypoint.sh"   23 hours ago        Up 21 hours               3306/tcp                                       r-wordpress_db_1

286de803b06c        gogs/gogs:latest                     "docker/start.sh /bin"   23 hours ago        Up 21 hours               0.0.0.0:222->22/tcp, 0.0.0.0:9093->3000/tcp    r-gogs_gogs_1

99697671f552        mariadb:latest                       "docker-entrypoint.sh"   24 hours ago        Up 21 hours               3306/tcp                                       r-owncloud_db_1

781376644b98        grafana/grafana:latest               "/run.sh"                24 hours ago        Up 21 hours               0.0.0.0:9094->3000/tcp                         r-grafana_grafana_1

 

在server节点,使用docker查询当前系统使用的卷组信息,将以上操作命令及检查结果填入命令行界面。

# docker volume ls

DRIVER              VOLUME NAME

local               0f272e99d983c52b7a1099b47158f261a3c8ed3b69ad6857980328bb37469c25

local               a4d71a18abf39258d66bd22e444d0b3740b1d09284035f0987d6faf4ee78ec17

local               a94e079509a6e13d69989d6a3b1bd478640cd57e47de1147939ee5dca68fbc6e

local               1211eb76e9d7f6302cb2a17de5a0a1077df10d069d35bb30dc11bf515d64e15f

server节点,启动镜像为ubuntu:14.04.3的镜像创建容器,容器挂载使用创建的为xd_volume的卷组挂载到root分区,完成后通过inspect指定查看容器的挂载情况,将以上操作命令及检查结果填入命令行界面。

[root@server opt]# docker volume create --name=xd_volume

xd_volume

[root@server opt]# docker run -dit -v xd_volume:/root/ ubuntu:14.04.3 /bin/bash

19fbb129fa1e0a0d2337305d9dd20a23bcaf5eabbb5d980bf99e7add0bbb563a

[root@server opt]# docker inspect -f '{{.HostConfig.Binds}}' 19fbb129fa1e

[xd_volume:/root/]

 

4.构建基础镜像

使用supermin5命令构建centos7系统的docker镜像,镜像名称为centos-7,镜像预装yum、net-tools、initscripts和vi命令,构建完成后提交镜像仓库上传操作完成后以运行该容器,查询容器的操作系统版本信息,提交查询docker容器列表信息、以上所有操作命令及执行结果填入命令行界面。

# supermin5 -v --prepare bash yum  net-tools initscripts  vi coreutils -o supermin.d

# supermin5 -v --build --format chroot supermin.d -o appliance.d

# echo 7 > appliance.d/etc/yum/vars/releasever

# tar --numeric-owner -cpf centos-7.tar -C appliance.d .

# cat centos-7.tar | docker import - 192.168.200.12:5000/centos-7

# docker push 192.168.200.12:5000/centos-7:latest

# docker run -i -t --rm 192.168.200.12:5000/centos-7 /bin/bash    

bash-4.2# cat /etc/redhat-release

Derived from Red Hat Enterprise Linux 7.1 (Source)

# docker images

REPOSITORY                                   TAG                 IMAGE ID            CREATED             SIZE

192.168.200.12:5000/centos-7                      latest              e40242986ac3        3 minutes ago       258.1 MB

5. 状态删除

在client节点查看各容器的id,使用过滤将所有处于Exited状态的容器删除,将操作命令及查询结果填入命令行界面。

# docker ps -a

CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS                      PORTS                                          NAMES

9da098d227fb        ubuntu:14.04.3                   "/bin/bash"              5 minutes ago       Up 5 minutes                                                               insane_snyder

7d85d770ffe9        opensaas/concrete5:latest        "apache2-foreground"     24 minutes ago      Up 24 minutes               80/tcp                                         r-Concrete5_Concrete5App_1

20bd10052310        opensaas/concrete5:latest        "bash -c 'chown -R ww"   24 minutes ago      Exited (1) 22 minutes ago                                                  r-Concrete5_Concrete5App_CMSConfig_1

f723b2459935        mysql:latest                     "docker-entrypoint.sh"   25 minutes ago      Up 25 minutes               3306/tcp                                       r-Concrete5_CMSMysql_1

cf2cee039edd        jenkins:1.651.3                  "/usr/share/jenkins/r"   30 minutes ago      Up 30 minutes               50000/tcp, 0.0.0.0:8082->8080/tcp              r-jenkins-ci_jenkins-primary_1

aaa85cc7d545        rancher/jenkins-plugins:v0.1.1   "/confd --backend ran"   31 minutes ago      Up 31 minutes                                                              r-jenkins-ci_jenkins-primary_jenkins-plugins_1

2376ca341634        busybox:latest                   "chown -R 1000:1000 /"   31 minutes ago      Exited (0) 31 minutes ago                                                  r-jenkins-ci_jenkins-primary_jenkins-datavolume_1

cc79715e0c5b        wordpress:latest                 "docker-entrypoint.sh"   37 minutes ago      Up 37 minutes               0.0.0.0:8083->80/tcp                           r-wordpress_wordpress_1

76d025a120d4        mariadb:latest                   "docker-entrypoint.sh"   38 minutes ago      Up 38 minutes               3306/tcp                                       r-wordpress_db_1

3d3926cbc40a        rancher/agent-instance:v0.8.3    "/etc/init.d/agent-in"   38 minutes ago      Up 38 minutes               0.0.0.0:500->500/udp, 0.0.0.0:4500->4500/udp   5e748e03-3ff0-472c-893a-73567bf1dab8

fb31f3d1f253        rancher/agent:v1.0.2             "/run.sh run"            40 minutes ago      Up 40 minutes                                                              rancher-agent

fd07017d0dde        rancher/agent:v1.0.2             "/run.sh state"          40 minutes ago      Exited (0) 40 minutes ago                                                  rancher-agent-state

5a8aaf8075b4        rancher/agent:v1.0.2             "/run.sh http://192.1"   40 minutes ago      Exited (0) 40 minutes ago                                                  modest_carson

# docker rm $(docker ps -a -q -f status=exited)

cf2cee039edd

aaa85cc7d545

2376ca341634

fd07017d0dde

Failed to remove container (5a8aaf8075b4): Error response from daemon: Unable to remove filesystem for 5a8aaf8075b4962e99e254dac662960812d352ef282821330c2c2213be5d040b: remove /var/lib/docker/containers/5a8aaf8075b4962e99e254dac662960812d352ef282821330c2c2213be5d040b/shm: device or resource busy

你可能感兴趣的:(docker之操作管理应用模板、镜像、容器、构建基础镜像、状态删除)