Learn what restart policies do and how to use them
Make sure Docker is installed on your system and the service is started
# Fedora/RHEL/CentOS
rpm -qa | grep docker
systemctl status docker
- Run a container with the following properties:
- image: alpine
- name: forest
- restart policy: always
- command to execute: sleep 15
- Run
docker container ls
- Is the container running? What about after 15 seconds, is it still running? why? - How then can we stop the container from running?
- Remove the container you've created
- Run the same container again but this time with
sleep 600
and verify it runs - Restart the Docker service. Is the container still running? why?
- Update the policy to
unless-stopped
- Stop the container
- Restart the Docker service. Is the container running? why?