簡單啓動一個Dokcer容器-02

1、Docker啓動容器步驟

(1)搜索鏡像
    [root@elk_134 ~]# docker search imagename

(2)拉取鏡像
    [root@elk_134 ~]# docker pull imagename

(3)基於Docker啓動鏡像爲容器
    [root@elk_134 ~]# docker run --name "containername" options imagename

2、基於鏡像啓動一個Nginx容器

(1)搜索nginx鏡像,咱們使用name爲nginx的第一個鏡像
    [root@elk_134 ~]# docker search nginx | awk '{print $1}'
    NAME
    nginx
    jwilder/nginx-proxy
    richarvey/nginx-php-fpm
    bitnami/nginx
    linuxserver/nginx
    tiangolo/nginx-rtmp
    nginx/nginx-ingress
    schmunk42/nginx-redirect
    arm64v8/nginx
    nginxdemos/hello
    crunchgeek/nginx-pagespeed
    blacklabelops/nginx
    centos/nginx-18-centos7
    centos/nginx-112-centos7
    webdevops/nginx
    nginxinc/nginx-unprivileged
    sophos/nginx-vts-exporter
    1science/nginx
    nginx/nginx-prometheus-exporter
    mailu/nginx
    travix/nginx
    pebbletech/nginx-proxy
    wodby/nginx
    centos/nginx-110-centos7
    ansibleplaybookbundle/nginx-apb

(2)拉取這個鏡像,latest爲最新穩定版
    [root@elk_134 ~]# docker pull nginx:latest
    Using default tag: latest
    latest: Pulling from library/nginx
    Digest: sha256:23b4dcdf0d34d4a129755fc6f52e1c6e23bb34ea011b315d87e193033bcd1b68
    Status: Image is up to date for nginx:latest

(3)基於這個nginx鏡像啓動爲容器
    [root@elk_134 ~]# docker run --name "nginx-web1" -d nginx:latest
    7c446cfc8b63cfd4d0e099640a0e7b2a83664d0fe117f1c3dd98bc56a808e206

(4)查看一下這個容器的IP地址,而後使用curl訪問一下nginx默認頁面
    [root@elk_134 ~]# docker inspect nginx-web1 | grep "IPAddress"                              
    "SecondaryIPAddresses": null,
    "IPAddress": "10.1.1.2",
    "IPAddress": "10.1.1.2",

    [root@elk_134 ~]# curl http://10.1.1.2
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
    body {
    width: 35em;
    margin: 0 auto;
    font-family: Tahoma, Verdana, Arial, sans-serif;
    }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>

一步一步來!!!!!!!!!!!!!!!!!!!!!!
其實很簡單噠!!!!!!!!!!!!!!!!!!!!!php

相關文章
相關標籤/搜索