Create image from container
docker commit c7e6409a22bf my-new-image
Start containers automatically
New container
docker run -d –restart unless-stopped redis
Update existing container
docker update –restart unless-stopped redis
Parameters
- no: Don’t automatically restart the container. (Default)
- on-failure[:max-retries]: Restart the container if it exits due to an error, which manifests as a non-zero exit code. Optionally, limit the number of times the Docker daemon attempts to restart the container using the :max-retries option. The on-failure policy only prompts a restart if the container exits with a failure. It doesn’t restart the container if the daemon restarts.
- always: Always restart the container if it stops. If it’s manually stopped, it’s restarted only when Docker daemon restarts or the container itself is manually restarted. (See the second bullet listed in restart policy details)
- unless-stopped: Similar to always, except that when the container is stopped (manually or otherwise), it isn’t restarted even after Docker daemon restarts.