I have a docker container, that i need to start on server boot.
The docker-compose.yml file i used to create this docker container is
[root@cp03 serverok-rubycms]# cat docker-compose.yml version: '3' services: web: image: serverok/rubycms:1.0 command: bash -c "rm -f tmp/pids/server.pid && cd /myapp && source /etc/profile.d/rvm.sh && script/server -e production" volumes: - /home/naiwnyc/cms:/myapp ports: - "3000:3000" [root@cp03 serverok-rubycms]#
With above docker-compose.yml file. i have to start docker container manually after server reboot.
To make it auto start, add the line
restart: always
Here is the modified docker-compose.yml file.
[root@cp03 serverok-rubycms]# cat docker-compose.yml version: '3' services: web: image: serverok/rubycms:1.0 restart: always command: bash -c "rm -f tmp/pids/server.pid && cd /myapp && source /etc/profile.d/rvm.sh && script/server -e production" volumes: - /home/naiwnyc/cms:/myapp ports: - "3000:3000" [root@cp03 serverok-rubycms]#
You need to rebuild docker container based on this docker-compose.yml file
Change to the folder where your docker-compse.yml file is, in my case it was
cd ~/serverok-rubycms
Run
docker-compose down docker-compose up -d