zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Docker Swarm 基础2

2023-03-20 14:59:29 时间

准备

要在每一台服务器上安装Docker

相关的安装过程可以参考 Docker 基础

关键是要使用如下配置启动服务

[root@h104 ~]# docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
WARN[0000] /! DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /! 
INFO[0000] API listen on [::]:2375                      
INFO[0000] API listen on /var/run/docker.sock           
WARN[0000] Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section. 
INFO[0000] [graphdriver] using prior storage driver "devicemapper" 
INFO[0000] Firewalld running: true                      
INFO[0000] Default bridge (docker0) is assigned with an IP address 172.17.0.1/16. Daemon option --bip can be used to set a preferred IP address 
INFO[0000] Loading containers: start.                   
........
INFO[0000] Loading containers: done.                    
INFO[0000] Daemon has completed initialization          
INFO[0000] Docker daemon                                 commit=a34a1d5 execdriver=native-0.2 graphdriver=devicemapper version=1.9.1
...
...
...

Note: 如不指定,默认会以 /usr/bin/docker daemon -H fd:// 的方式启动服务,这将导致 swarm 无法通过 2375 端口接受请求,node 会一直都处于 Pending 状态

安装完成后,可以使用 hello-world 镜像来检测是否运行成功

[root@h104 ~]# docker run hello-world

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/userguide/

[root@h104 ~]#