-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestart-policies.txt
34 lines (22 loc) · 1.25 KB
/
restart-policies.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// https://docs.docker.com/config/containers/start-containers-automatically/
https://www.cloudsavvyit.com/10912/how-to-use-docker-restart-policies-to-keep-containers-running/#:~:text=The%20on%2Dfailure%20restart%20policy,start%20multiple%20times%20in%20succession.&text=In%20this%20example%2C%20Docker%20will,non%2Dzero%20exit%20code).
// Run a container without specifying a restart policy
docker run -d alpine sleep infinity
// Restart always
// Restart container if it stops or when docker daemon restarts
docker run -d --restart always alpine sleep infinity
// Restart container unless if it gets stopped
docker run -d --restart unless-stopped alpine
// Run a container giving it a name
docker run -d --restart unless-stopped --name unless-16 alpine sleep infinity
// Manually stop a container
docker stop unless-16
// Restart a container when it fails until a maximum failure limit is exceeded
// Notice that docker will only restart if the container stopped with a non-zero exit code meaning an error occured that stopped the container.
docker run -d --restart on-failure:10000 alpine sleep infinity
// See details of all containers, both stopped and running
docker ps -a
// or
docker container ls -a
// See container logs
docker logs b2a30743bac5