Having done this, you must stop the running container, remove it, and run a container with the newer image version as shown in Example 7-5 on page 147. 

VL1:/home/admin> docker stop grafana grafana VL1:/home/admin> docker rm grafana grafana VL1:/home/admin> docker run -d -p 3000:3000 --name grafana ibmcom/grafana-s390x:5.2.0-f3 08acc3fcd0f898f6b758072cdadcbcbdc0f364ddd91fb98a667c470b3caab2da 

Any changes that have been done to the container are lost through the replacement. The changes must be done again to the new image. 

Therefore, you should avoid applying customizations to a container within files of that container. If it is not possible or not desired to specify the needed configuration through parameters to the docker run  command, consider the following approach: Mount a Docker volume to that container to hold the configurations . For more information on this approach, see Chapter 10, “Persistent data” on page 233. 

## Maintenance through the use of Docker swarm 

If you run your Docker container as a Docker swarm service, you can use the swarm capabilities to upgrade your container to a new software level. The preceding point about changed files within the container also applies to maintenance, when you use Docker swarm. 

For more details about setting up Docker swarm and a Docker swarm service see Chapter 11, “Swarm on zCX” on page 241. Example 7-6 uses the docker service create  command to create a service that runs Grafana. 

VL1:/home/admin> docker service create --name grafana --replicas 1 -p 3000:3000 ibmcom/grafana-s390x:5.2.0-f2 xj4hbcpgcwp6hmoosirbdyrk5 overall progress: 1 out of 1 tasks 1/1: running [==================================================>] verify: Service converged VL1:/home/admin> docker service ps grafana ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS mqqiyxmgt8sr grafana.1 ibmcom/grafana-s390x:5.2.0-f2 sc74cn15.pbm.ihost.com Running Running 51 seconds ago 

To update the level of a swarm service, you must first pull the image with the new level to the zCX instances where the service will be deployed as shown in the preceding section in Example 7-4 on page 146. 

Then, you issue the docker service update  command with the --image parameter. And you point to the new image level as shown in Example 7-7 on page 148. 

