Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 521
TajnosAgentos Avatar asked Jan 29 '23 14:01

TajnosAgentos


1 Answers

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.

like image 64
Sergiu Avatar answered Feb 01 '23 03:02

Sergiu