Then the article, found that start every time Redis too much trouble, the best container along with Docker start
Added directly when first start
docker run -d --restart=always myredis
The second strategy corresponds directly modify the start of the container, when the container myredis exit strategy to adopt new start
docker container update --restart=always myredis
The third container directly modify the configuration files docker
1. docker stop myredis
Container id 2. cd / var / lib / docker / container / myredis of
3. vim hostconfig.json
4. Adoption / RestartPolicy find command to restart strategy is no
5. Modification to always
6. Restart container
As follows:
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6472f47fca2 redis "docker-entrypoint.s…" About an hour ago Up 30 minutes 0.0.0.0:6379->6379/tcp myredis
[root@localhost ~]# docker stop myredis
[root@localhost ~]# cd /var/lib/docker/containers/f6472f47fca25..../
[root@localhost f6472f47fca25843214a92b9a22179e7e6c7bafc32c88a7215cc43dd3820c147]# ll
drwx------. 2 root root 6 5月 3 09:49 checkpoints
-rw-------. 1 root root 3643 5月 3 10:48 config.v2.json
-rw-r-----. 1 root root 30326 5月 3 10:48 f6472f47fca25843214a92b9a22179e7e6c7bafc32c88a7215cc43dd3820c147-json.log
-rw-r--r--. 1 root root 1530 5月 3 10:48 hostconfig.json
-rw-r--r--. 1 root root 13 5月 3 10:48 hostname
-rw-r--r--. 1 root root 174 5月 3 10:48 hosts
drwx------. 3 root root 16 5月 3 09:49 mounts
-rw-r--r--. 1 root root 55 5月 3 10:48 resolv.conf
-rw-r--r--. 1 root root 71 5月 3 10:48 resolv.conf.hash
Modify hostconfig.json in RestartPolicy
原始:"RestartPolicy":{"Name":"no","MaximumRetryCount":0}
修改后: "RestartPolicy":{"Name":"always","MaximumRetryCount":0}
By jq View
Restart docker found myredis has started!
Official Command Manual: https://docs.docker.com/engine/reference/commandline/run/