(一)Docker 在线部署和离线部署

环境:CentOS7.3

1.在线部署

[root@hadoop004 ~]# yum install -y httpd
[root@hadoop004 ~]# service httpd start
Redirecting to /bin/systemctl start  httpd.service
[root@hadoop004 ~]# netstat -nlp|grep httpd
-bash: netstat: command not found
[root@hadoop004 ~]# yum install -y net-tools
[root@hadoop004 ~]# netstat -nlp|grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      9538/httpd 
[root@hadoop004 ~]# yum install -y yum-utils
[root@hadoop004 ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@hadoop004 ~]# cd /etc/yum.repos.d/ 
[root@hadoop004 yum.repos.d]# ll
total 32
-rw-r--r--. 1 root root 1664 Nov 30  2016 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 30  2016 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 30  2016 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 30  2016 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 30  2016 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 30  2016 CentOS-Sources.repo
-rw-r--r--. 1 root root 2893 Nov 30  2016 CentOS-Vault.repo
-rw-r--r--  1 root root 2424 Oct 25 01:22 docker-ce.repo
[root@hadoop004 ~]# yum makecache fast
[root@hadoop004 ~]# yum install -y docker-ce

2.离线部署

step1:rz上传
step2:[root@hadoop004 ~]# yum install -y ./docker-ce-18.06.1.ce-3.el7.x86_64.rpm

3.启动服务

//启动服务端
[root@hadoop004 ~]# /bin/systemctl start docker.service
[root@hadoop004 ~]# /bin/systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-11-13 22:00:55 CST; 10s ago
     Docs: https://docs.docker.com
 Main PID: 23182 (dockerd)
   Memory: 47.9M
   CGroup: /system.slice/docker.service
           ├─23182 /usr/bin/dockerd
           └─23189 docker-containerd --config /var/run/docker/containerd/cont...

Nov 13 22:00:55 hadoop004 dockerd[23182]: time="2018-11-13T22:00:55.75403948...c
Nov 13 22:00:55 hadoop004 dockerd[23182]: time="2018-11-13T22:00:55.75405645..."
Nov 13 22:00:55 hadoop004 dockerd[23182]: time="2018-11-13T22:00:55.86005587..."
Nov 13 22:00:55 i-mulkuzbd dockerd[23182]: time="2018-11-13T22:00:55.9317044..."
Nov 13 22:00:55 i-mulkuzbd dockerd[23182]: time="2018-11-13T22:00:55.9330681...2
Nov 13 22:00:55 i-mulkuzbd dockerd[23182]: time="2018-11-13T22:00:55.9412118...e
Nov 13 22:00:55 i-mulkuzbd dockerd[23182]: time="2018-11-13T22:00:55.9413342..."
Nov 13 22:00:55 i-mulkuzbd dockerd[23182]: time="2018-11-13T22:00:55.9549998..."
Nov 13 22:00:55 i-mulkuzbd systemd[1]: Started Docker Application Container...e.
Nov 13 22:00:55 i-mulkuzbd dockerd[23182]: time="2018-11-13T22:00:55.9643309..."
Hint: Some lines were ellipsized, use -l to show in full.

4.运行一个镜像测试

[root@hadoop004 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally  //hello-world:latest---镜像名:版本号
latest: Pulling from library/hello-world   //官方仓库:https://hub.docker.com
d1725b59e92d: Pull complete 
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for 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/get-started/

你可能感兴趣的:((一)Docker 在线部署和离线部署)