在守护程序模式下运行Docker [英] Run Docker in daemon mode

查看:229
本文介绍了在守护程序模式下运行Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发出了此命令

sudo docker daemon -H unix:///var/run/docker.sock -H tcp:// xxxx:8400 -H tcp:// yyyyy:2375&

sudo docker daemon -H unix:///var/run/docker.sock -H tcp://xxxx:8400 -H tcp://yyyyy:2375 &

工作正常。但它不会返回我的控制台客户端。它没有完成命令。

It working fine. but it not returning to my console client. it not finishing the command.

WARN[0000] /!\ DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /!\ 
WARN[0000] /!\ DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /!\ 
INFO[0000] [graphdriver] using prior storage driver "aufs" 
INFO[0000] Graph migration to content-addressability took 0.00 seconds 
INFO[0000] Firewalld running: false                     
INFO[0000] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address 
WARN[0000] Your kernel does not support swap memory limit. 
INFO[0000] Loading containers: start.                   
.
INFO[0000] Loading containers: done.                    
INFO[0000] Daemon has completed initialization          
INFO[0000] Docker daemon                                 commit=20f81dd execdriver=native-0.2 graphdriver=aufs version=1.10.3
INFO[0000] API listen on 172.31.16.21:2375              
INFO[0000] API listen on /var/run/docker.sock           
INFO[0000] API listen on 172.31.16.21:8400 

这次我可以从外部客户端访问它。但是如果杀死那个控制台。我无法从外部客户端访问它。

this time I can access it from out side client. but if kill that console. I cannot access it from out side client.

对此有什么解决方案?

any solution for this?

不知道为什么docker对于初学者如此复杂:)

don't know why docker becoming so complex for the beginners :)

推荐答案

在我再说什么之前,我需要警告您不要像这样运行Docker守护程序,监听TCP连接而不是Unix文件套接字连接。您可能不会听我的话,但是如果您有空,应该阅读我将要链接的文档中的警告,因为这样做很危险。因此,无论如何...当您应该更改docker的初始化选项时,您正在运行docker守护程序。 文档详细信息,您应该编辑哪个文件为了更改Docker守护程序的配置。 请注意,运行命令和配置文件中的重复选项将意味着守护程序将无法启动。因此,如果您更改 daemon.json file并尝试使用这些命令行选项运行守护程序,服务器将忽略它们。要编辑的文件是 /etc/docker/daemon.json ,您应该在此处设置以下选项:

Before I say anything else, I need to warn you against running the Docker daemon like this, listening for TCP connections instead of Unix file socket connections. You probably won't listen to me, but when you get some time, you should read the warnings in the documentation I am about to link, because it's dangerous. So, anyways... You are running a docker daemon when you should be changing your initialization options for docker. The documentation details for you which file you should edit in order to change the configuration for the Docker daemon. Be advised that duplicate options in your run command and in the config file will mean that the daemon will not start. So if you change your daemon.json file and also try to run the daemon with those command line options, your server will ignore them both. The file to edit is /etc/docker/daemon.json, and you should set those options in there like this:

{
  hosts: [
    'unix:///var/run/docker.sock',
    'tcp://xxxx:8400',
    'tcp://yyyyy:2375'
  ]
}

编辑完该文件后,现在应该重新启动docker守护进程:

Once you have edited that file, you now should restart your docker daemon:

sudo service docker restart

或者如果您使用的是systemd:

Or if you're using systemd:

sudo systemctl restart docker.service

这也是您的中心问题体验与在终端内部运行守护进程有关。将来,请查看 nohup 命令,该命令用于在终端中运行进程并在关闭终端后使其保持活动状态。您可以在 man nohup 中阅读更多内容。

Also the central problem you are experiencing has to do with running a daemon process inside of a terminal. In the future, look at the nohup command for running a process inside your terminal and keeping it alive after you close the terminal. You can read more at man nohup.

这篇关于在守护程序模式下运行Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆