Based on the following Beginner Course:
https://www.safaribooksonline.com/library/view/docker-for-the/9781788991315/
OS information:
[root@docker1 ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.5.1804 (Core)
Release: 7.5.1804
Codename: Core
[root@docker1 ~]# ip a show eth0
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:20:ef:be brd ff:ff:ff:ff:ff:ff
inet 192.168.122.178/24 brd 192.168.122.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe20:efbe/64 scope link
valid_lft forever preferred_lft forever
[root@docker1 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search ab.lab
nameserver 192.168.122.1
nameserver 8.8.8.8
[root@docker1 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.122.1 0.0.0.0 UG 100 0 0 eth0
192.168.122.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
Install Docker:
[root@docker1 ~]# yum install docker
[root@docker1 ~]# systemctl enable docker --now
Test your installation:
[root@docker1 ~]# docker --version
Docker version 1.13.1, build 94f4240/1.13.1
[root@docker1 ~]# docker -h
[root@docker1 ~]# docker help image
[root@docker1 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@docker1 ~]# docker search hello | head -n2
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/hello-world Hello World! (an example of minimal Docker... 526 [OK]
[root@docker1 ~]# docker pull hello-world
Using default tag: latest
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for docker.io/hello-world:latest
[root@docker1 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for docker.io/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.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
[root@docker1 ~]# hostname
docker1.ab.lab
[root@docker1 ~]# docker help run | grep -E -e "[[:space:]] -i" -e "[[:space:]]-t"
-i, --interactive Keep STDIN open even if not attached
-t, --tty Allocate a pseudo-TTY
[root@docker1 ~]# docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
Trying to pull repository docker.io/library/ubuntu ...
latest: Pulling from docker.io/library/ubuntu
a48c500ed24e: Pull complete
1e1de00ff7e1: Pull complete
0330ca45a200: Pull complete
471db38bcfbf: Pull complete
0b4aba487617: Pull complete
Digest: sha256:c8c275751219dadad8fa56b3ac41ca6cb22219ff117ca98fe82b42f24e1ba64e
Status: Downloaded newer image for docker.io/ubuntu:latest
root@18a61e60f7fa:/# hostname
18a61e60f7fa
root@18a61e60f7fa:/# exit
[root@docker1 ~]# hostname
docker1.ab.lab
[root@docker1 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu latest 452a96d81c30 3 weeks ago 79.6 MB
docker.io/hello-world latest e38bc07ac18e 5 weeks ago 1.85 kB
No comments:
Post a Comment