问题
I issued this command
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?
don't know why docker becoming so complex for the beginners :)
回答1:
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'
]
}
Once you have edited that file, you now should restart your docker daemon:
sudo service docker restart
Or if you're using systemd:
sudo systemctl restart docker.service
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
.
来源:https://stackoverflow.com/questions/35969721/run-docker-in-daemon-mode