If itβs normal for the container to be online, why not just remove and start again without port switches?
If you need to do this without removing the containers, you can simply change the main iptables changes.
Usually your data should always be in one of 3 places.
- A data container that may be associated with a restarted service container.
- The amount defined in the service container than can be associated with the new container for backup. See here for an example.
- In a host mounted volume so that you can restart containers and set the same location to new containers.
With one of these three approaches, restarting services becomes easy, and this should be standard, as microservices must be designed so that they can often go down and recover. These approaches will also speed up your application because the default federated file system is slower than the regular file systems that are used for volumes.
If you need to restore data from a container where you did not plan the correct volumes, you can use the docker export function to export the status of your container. Then import it into a new container with the volume installed. Copy your critical data from the container in volume.
source share