Monday, 26 December 2016

03- Base Images

- Currently, there are no docker images added yet:
[user@docker ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
- You can try to search whatever distro you want, for example: search for CentOS (First item is the official docker image for CentOS distro):
[user@docker ~]$ docker help search

Usage: docker search [OPTIONS] TERM

Search the Docker Hub for images

Options:
  -f, --filter value   Filter output based on conditions provided (default [])
      --help           Print usage
      --limit int      Max number of search results (default 25)
      --no-trunc       Don't truncate output
[user@docker ~]$ docker search centos
NAME                       DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
centos                     The official build of CentOS.                   2949      [OK]       
jdeathe/centos-ssh         CentOS-6 6.8 x86_64 / CentOS-7 7.3.1611 x8...   51                   [OK]
nimmis/java-centos         This is docker images of CentOS 7 with dif...   20                   [OK]
torusware/speedus-centos   Always updated official CentOS docker imag...   8                    [OK]
nathonfowlie/centos-jre    Latest CentOS image with the JRE pre-insta...   5                    [OK]
centos/mariadb55-centos7                                                   3                    [OK]
harisekhon/centos-java     Java on CentOS (OpenJDK, tags jre/jdk7-8)       2                    [OK]
centos/tools               Docker image that has systems administrati...   2                    [OK]
timhughes/centos           Centos with systemd installed and running       1                    [OK]
blacklabelops/centos       CentOS Base Image! Built and Updates Daily!     1                    [OK]
harisekhon/centos-scala    Scala + CentOS (OpenJDK tags 2.10-jre7 - 2...   1                    [OK]
sgfinans/docker-centos     CentOS with a running sshd and Docker           1                    [OK]
darksheer/centos           Base Centos Image -- Updated hourly             1                    [OK]
centos/redis               Redis built for CentOS                          1                    [OK]
januswel/centos            yum update-ed CentOS image                      0                    [OK]
kz8s/centos                Official CentOS plus epel-release               0                    [OK]
grayzone/centos            auto build for centos.                          0                    [OK]
smartentry/centos          centos with smartentry                          0                    [OK]
grossws/centos             CentOS 6 and 7 base images with gosu and l...   0                    [OK]
aguamala/centos            CentOS base image                               0                    [OK]
repositoryjp/centos        Docker Image for CentOS.                        0                    [OK]
vcatechnology/centos       A CentOS Image which is updated daily           0                    [OK]
ustclug/centos              USTC centos                                    0                    [OK]
dmglab/centos              CentOS with some extras - This is for the ...   0                    [OK]
termbox/centos             CentOS                                          0                    [OK]

- For now, we will pull (download) small docker image:
[user@docker ~]$ docker search hello-world
NAME                                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
hello-world                               Hello World! (an example of minimal Docker...   225       [OK]       
tutum/hello-world                         Image to test docker deployments. Has Apac...   29                   [OK]
dockercloud/hello-world                   Hello World!                                    9                    [OK]
marcells/aspnet-hello-world               ASP.NET vNext - Hello World                     4                    [OK]
bonomat/nodejs-hello-world                a simple nodejs hello world container           2                    [OK]
carinamarina/hello-world-app              This is a sample Python web application, r...   1                    [OK]
asakaguchi/docker-nodejs-hello-world      Hello World for Docker                          1                    [OK]
mikespuborg/dockercloud-hello-world       Fix dockercloud-hello-world example for al...   1                    [OK]
yesimages/hello-world                     exercise java hello-world app                   1                    [OK]
scottnakada/angular2-docker-hello-world   Angular 2 Hello World Sample Application u...   1                    [OK]
neoxsys/hello-world                       hello-world container based on Ubuntu 16.0...   1                    [OK]
wowgroup/hello-world                      Minimal web app for testing purposes            0                    [OK]
waleedsamy/hello-world-expressjs-docker   Hello world express sample, return `Hello ...   0                    [OK]
helloworld314/hello-world-docker          Hello world docker                              0                    [OK]
palamccc/node-hello-world                 node-hello-world                                0                    [OK]
wodge/docker-hello-world                  Hello World test for auto update to Docker...   0                    [OK]
cyfratech/hello-world                     Hello World node.js application                 0                    [OK]
brogency/hello-world                      simple docker hello world​ app powered b...     0                    [OK]
n8io/hello-world                          A simple hello world node.js app to test d...   0                    [OK]
nirmata/hello-world                                                                       0                    [OK]
navycloud/hello-world                     Navy hello world                                0                    [OK]
jmreeve007/hello-world                    Create automated build for changes to hell...   0                    [OK]
gscrivano/hello-world                     hello world example system container            0                    [OK]
edenb1515/hello-world                     hello                                           0                    [OK]
mdzhang/docker-sinatra-hello-world        (WIP) Hello World web app using Docker, Si...   0                    [OK]
[user@docker ~]$ docker help pull

Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST]

Pull an image or a repository from a registry

Options:
  -a, --all-tags                Download all tagged images in the repository
      --disable-content-trust   Skip image verification (default true)
      --help                    Print usage
[user@docker ~]$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest

- Now, You have new added image:
[user@docker ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              c54a2cc56cbb        5 months ago        1.848 kB


- You can run the above docker image using either the REPOSITORY name + TAG OR Image ID:

1. "docker run" command help message:
[user@docker ~]$ docker help run

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

Options:
      --add-host value              Add a custom host-to-IP mapping (host:ip) (default [])
  -a, --attach value                Attach to STDIN, STDOUT or STDERR (default [])
      --blkio-weight value          Block IO (relative weight), between 10 and 1000
      --blkio-weight-device value   Block IO weight (relative device weight) (default [])
      --cap-add value               Add Linux capabilities (default [])
      --cap-drop value              Drop Linux capabilities (default [])
      --cgroup-parent string        Optional parent cgroup for the container
      --cidfile string              Write the container ID to the file
      --cpu-percent int             CPU percent (Windows only)
      --cpu-period int              Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int               Limit CPU CFS (Completely Fair Scheduler) quota
  -c, --cpu-shares int              CPU shares (relative weight)
      --cpuset-cpus string          CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string          MEMs in which to allow execution (0-3, 0,1)
  -d, --detach                      Run container in background and print container ID
      --detach-keys string          Override the key sequence for detaching a container
      --device value                Add a host device to the container (default [])
      --device-read-bps value       Limit read rate (bytes per second) from a device (default [])
      --device-read-iops value      Limit read rate (IO per second) from a device (default [])
      --device-write-bps value      Limit write rate (bytes per second) to a device (default [])
      --device-write-iops value     Limit write rate (IO per second) to a device (default [])
      --disable-content-trust       Skip image verification (default true)
      --dns value                   Set custom DNS servers (default [])
      --dns-opt value               Set DNS options (default [])
      --dns-search value            Set custom DNS search domains (default [])
      --entrypoint string           Overwrite the default ENTRYPOINT of the image
  -e, --env value                   Set environment variables (default [])
      --env-file value              Read in a file of environment variables (default [])
      --expose value                Expose a port or a range of ports (default [])
      --group-add value             Add additional groups to join (default [])
      --health-cmd string           Command to run to check health
      --health-interval duration    Time between running the check
      --health-retries int          Consecutive failures needed to report unhealthy
      --health-timeout duration     Maximum time to allow one check to run
      --help                        Print usage
  -h, --hostname string             Container host name
  -i, --interactive                 Keep STDIN open even if not attached
      --io-maxbandwidth string      Maximum IO bandwidth limit for the system drive (Windows only)
      --io-maxiops uint             Maximum IOps limit for the system drive (Windows only)
      --ip string                   Container IPv4 address (e.g. 172.30.100.104)
      --ip6 string                  Container IPv6 address (e.g. 2001:db8::33)
      --ipc string                  IPC namespace to use
      --isolation string            Container isolation technology
      --kernel-memory string        Kernel memory limit
  -l, --label value                 Set meta data on a container (default [])
      --label-file value            Read in a line delimited file of labels (default [])
      --link value                  Add link to another container (default [])
      --link-local-ip value         Container IPv4/IPv6 link-local addresses (default [])
      --log-driver string           Logging driver for the container
      --log-opt value               Log driver options (default [])
      --mac-address string          Container MAC address (e.g. 92:d0:c6:0a:29:33)
  -m, --memory string               Memory limit
      --memory-reservation string   Memory soft limit
      --memory-swap string          Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --memory-swappiness int       Tune container memory swappiness (0 to 100) (default -1)
      --name string                 Assign a name to the container
      --network string              Connect a container to a network (default "default")
      --network-alias value         Add network-scoped alias for the container (default [])
      --no-healthcheck              Disable any container-specified HEALTHCHECK
      --oom-kill-disable            Disable OOM Killer
      --oom-score-adj int           Tune host's OOM preferences (-1000 to 1000)
      --pid string                  PID namespace to use
      --pids-limit int              Tune container pids limit (set -1 for unlimited)
      --privileged                  Give extended privileges to this container
  -p, --publish value               Publish a container's port(s) to the host (default [])
  -P, --publish-all                 Publish all exposed ports to random ports
      --read-only                   Mount the container's root filesystem as read only
      --restart string              Restart policy to apply when a container exits (default "no")
      --rm                          Automatically remove the container when it exits
      --runtime string              Runtime to use for this container
      --security-opt value          Security Options (default [])
      --shm-size string             Size of /dev/shm, default value is 64MB
      --sig-proxy                   Proxy received signals to the process (default true)
      --stop-signal string          Signal to stop a container, SIGTERM by default (default "SIGTERM")
      --storage-opt value           Storage driver options for the container (default [])
      --sysctl value                Sysctl options (default map[])
      --tmpfs value                 Mount a tmpfs directory (default [])
  -t, --tty                         Allocate a pseudo-TTY
      --ulimit value                Ulimit options (default [])
  -u, --user string                 Username or UID (format: [:])
      --userns string               User namespace to use
      --uts string                  UTS namespace to use
  -v, --volume value                Bind mount a volume (default [])
      --volume-driver string        Optional volume driver for the container
      --volumes-from value          Mount volumes from the specified container(s) (default [])
  -w, --workdir string              Working directory inside the container

2. Running docker image using its REPOSITORY name + TAG:
[user@docker ~]$ docker run hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

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 Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
[user@docker ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              c54a2cc56cbb        5 months ago        1.848 kB

3. Running docker image using IMAGE ID:
[user@docker ~]$ docker run c54a2cc56cbb

Hello from Docker!
This message shows that your installation appears to be working correctly.

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 Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/


- Now, You are going to pull CnetOS images. You can specify MORE than one images:

1. Pull latest CnetOS image:
[user@docker ~]$ docker pull centos
Using default tag: latest
latest: Pulling from library/centos

45a2e645736c: Pull complete 
Digest: sha256:c577af3197aacedf79c5a204cd7f493c8e07ffbce7f88f7600bf19c688c38799
Status: Downloaded newer image for centos:latest
[user@docker ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              67591570dd29        11 days ago         191.8 MB
hello-world         latest              c54a2cc56cbb        5 months ago        1.848 kB

2. Pull Specific CentOS image (in this example CentOS 6):
[user@docker ~]$ docker pull centos:centos6
centos6: Pulling from library/centos

32c4f4fef1c6: Pull complete 
Digest: sha256:1092df198d3da4faccc0660941b763ce5adf133b0ec71701b760d6f173c1f47b
Status: Downloaded newer image for centos:centos6
[user@docker ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              67591570dd29        11 days ago         191.8 MB
centos              centos6             8315978ceaaa        7 weeks ago         194.6 MB
hello-world         latest              c54a2cc56cbb        5 months ago        1.848 kB

- I will -also- Pull nginx images:
[user@docker ~]$ docker search nginx
NAME                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                     Official build of Nginx.                        4909      [OK]       
jwilder/nginx-proxy       Automated Nginx reverse proxy for docker c...   901                  [OK]
richarvey/nginx-php-fpm   Container running Nginx + PHP-FPM capable ...   322                  [OK]
million12/nginx-php       Nginx + PHP-FPM 5.5, 5.6, 7.0 (NG), CentOS...   75                   [OK]
webdevops/php-nginx       Nginx with PHP-FPM                              63                   [OK]
maxexcloo/nginx-php       Framework container with nginx and PHP-FPM...   58                   [OK]
h3nrik/nginx-ldap         NGINX web server with LDAP/AD, SSL and pro...   33                   [OK]
bitnami/nginx             Bitnami nginx Docker Image                      21                   [OK]
gists/nginx               Nginx on Alpine                                 8                    [OK]
evild/alpine-nginx        Minimalistic Docker image with Nginx            8                    [OK]
maxexcloo/nginx           Framework container with nginx installed.       7                    [OK]
webdevops/nginx           Nginx container                                 7                    [OK]
blacklabelops/nginx       Dockerized Nginx Reverse Proxy Server.          4                    [OK]
1science/nginx            Nginx Docker images that include Consul Te...   4                    [OK]
ixbox/nginx               Nginx on Alpine Linux.                          3                    [OK]
drupaldocker/nginx        NGINX for Drupal                                3                    [OK]
servivum/nginx            Nginx Docker Image with Useful Tools            2                    [OK]
frekele/nginx             docker run --rm --name nginx -p 80:80 -p 4...   2                    [OK]
yfix/nginx                Yfix own build of the nginx-extras package      2                    [OK]
xataz/nginx               Light nginx image                               2                    [OK]
dock0/nginx               Arch container running nginx                    2                    [OK]
tozd/nginx                Dockerized nginx.                               1                    [OK]
unblibraries/nginx        Baseline non-PHP nginx container                0                    [OK]
c4tech/nginx              Several nginx images for web applications.      0                    [OK]
watsco/nginx              nginx:1.11-alpine                               0                    [OK]

[user@docker ~]$ docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
75a822cd7888: Pull complete 
64f0219ba3ea: Pull complete 
325b624bee1c: Pull complete 
Digest: sha256:2a07a07e5bbf62e7b583cbb5257357c7e0ba1a8e9650e8fa76d999a60968530f
Status: Downloaded newer image for nginx:latest
[user@docker ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              19146d5729dc        6 days ago          181.6 MB
centos              latest              67591570dd29        11 days ago         191.8 MB
centos              centos6             8315978ceaaa        7 weeks ago         194.6 MB
hello-world         latest              c54a2cc56cbb        5 months ago        1.848 kB


- In order to inspect (show information about) image, you can use "docker inspect" command:

1. Inspect "nginx" image:
[user@docker ~]$ docker inspect nginx
[
    {
        "Id": "sha256:19146d5729dc303af0b89be53ddfe8ece1920d9467e2b5a903d846f2fe0e9b5d",
        "RepoTags": [
            "nginx:latest"
        ],
        "RepoDigests": [
            "nginx@sha256:2a07a07e5bbf62e7b583cbb5257357c7e0ba1a8e9650e8fa76d999a60968530f"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2016-12-20T19:45:40.527888877Z",
        "Container": "7ba1e7256528292bd4101713f0427b2b56e558e951a0f86172cd5d9a11fe5228",
        "ContainerConfig": {
            "Hostname": "45f28166fed1",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "443/tcp": {},
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.11.7-1~jessie"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"nginx\" \"-g\" \"daemon off;\"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:0a068f0983fd1af0af01514aa61169c1ccdd62c04442c842c95f01ff44c29a34",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {}
        },
        "DockerVersion": "1.12.3",
        "Author": "NGINX Docker Maintainers \"docker-maint@nginx.com\"",
        "Config": {
            "Hostname": "45f28166fed1",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "443/tcp": {},
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.11.7-1~jessie"
            ],
            "Cmd": [
                "nginx",
                "-g",
                "daemon off;"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:0a068f0983fd1af0af01514aa61169c1ccdd62c04442c842c95f01ff44c29a34",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {}
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 181566028,
        "VirtualSize": 181566028,
        "GraphDriver": {
            "Name": "devicemapper",
            "Data": {
                "DeviceId": "11",
                "DeviceName": "docker-202:2-850801-c8e2a0b64d8bcaa92288f6269c71663d42d1efc296e8499a6558de5a1b6feda6",
                "DeviceSize": "10737418240"
            }
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:b6ca02dfe5e62c58dacb1dec16eb42ed35761c15562485f9da9364bb7c90b9b3",
                "sha256:ee3b1534c826d789219ac39b263722c3af9f702610238e701b7d1ba41ac88fac",
                "sha256:e03d01018b72c0f7fcdad380d976cb01af9bc0afe52d1d6b8d5804959512c857"
            ]
        }
    }
]


2. Inspect "hello-world" image:
[user@docker ~]$ docker inspect hello-world
[
    {
        "Id": "sha256:c54a2cc56cbb2f04003c1cd4507e118af7c0d340fe7e2720f70976c4b75237dc",
        "RepoTags": [
            "hello-world:latest"
        ],
        "RepoDigests": [
            "hello-world@sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2016-07-01T19:39:27.532838486Z",
        "Container": "562cadb4d17bbf30b58ab0f6a870be60c8d36d2e401bf637f1d2d7f8afbef666",
        "ContainerConfig": {
            "Hostname": "c65bc554a4b7",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) CMD [\"/hello\"]"
            ],
            "Image": "sha256:0f9bb7da10de694b2babd0c1a3b75582a0db3395625cae5ab0fe537ce1cd831e",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "1.10.3",
        "Author": "",
        "Config": {
            "Hostname": "c65bc554a4b7",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/hello"
            ],
            "Image": "sha256:0f9bb7da10de694b2babd0c1a3b75582a0db3395625cae5ab0fe537ce1cd831e",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 1848,
        "VirtualSize": 1848,
        "GraphDriver": {
            "Name": "devicemapper",
            "Data": {
                "DeviceId": "2",
                "DeviceName": "docker-202:2-850801-3c6ab0acbcc8082fc922caf035a7af5d5d457f489e4888579848fc5aeb58cf61",
                "DeviceSize": "10737418240"
            }
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:a02596fdd012f22b03af6ad7d11fa590c57507558357b079c3e8cebceb4262d7"
            ]
        }
    }
]

No comments:

Post a Comment