简体   繁体   中英

Docker service start after server restart

I'm struggling with dockers (17) on Ubuntu(14). I have to run rabbitMQ on a couple of machines using docker technology. I managed to do that on one of them using

sudo docker service create -d --hostname my-rabbit --name some-rabbit -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password rabbitmq:3-management

but i encounter a problem on others. When i run Rabbit as a docker service everything is OK, but the problem starts after restarting the machine. After server reboot the docker is started automaticaly- i run

sudo docker service list
sudo docker ps

to check that. But when I want to connect to the rabbitServer using the browser nothing happens. When i use curl or wget inside the servier it waits for the response and nothing happens. when i run

sudo service docker restart

then everything starts to work like it should. the ports are open all the time, and the info is saved so after restart i dont have to reopen them. One of the machines does not have this problem and everything works even after restart

I believe it is because your docker daemon and / or containers doesn't start when you reboot the machine. To achieve that you should do something as follows:

sudo systemctl enable docker

This should start the Docker daemon after you reboot the host. Then what you will have to do is when you run the service is to pass

--restart-condition:any 

Which should start your containers in case or a system failure or reboot in this case.

It's weird and i still don't know why this works. After I rebooted the machine, then I restarted docker service as well and after that i saved again the ipconfig persistent configuration without adding anything to the rules- it started working on all of the machines

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM