When a Docker image has been updated, will restarting the running container via docker restart pick up the change? Educated guess will be no, because like restarting a process, the memory is still retained. The best way to find out is to give a try.
Step 2 : CMD while true; do echo bar; sleep 5; done
--->Running in 7fc297e12005
---> a6c04345afb9
Removing intermediate container 7fc297e12005
Successfully built a6c04345afb9
Now we have a different image. The image ID is different: a6c0. But the old image is still there:
1
2
3
4
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
example latest a6c04345afb9 24 seconds ago 125.1 MB
<none> <none> 6a56a50ef254 3 minutes ago 125.1MB
Restart the container:
1
2
$ docker restart example
example
Got bar? No still foo all the way with the log. And when you inspect the container, it still uses the old image.
So, docker restart will not pick up the changes from updated image, it will still use the old image built previously. Therefore, the correct way is to drop the container entirely and run it again:
1
2
3
4
$ docker stop example && docker rm example && docker run -d --name example example
A single Upstart job can have multiple instances running:
1
2
3
$ sudo start my-job port=4000
$ sudo start my-job port=4001
$ sudo start my-job port=4002
However, when the operating system reboots, the job with multiple instances will fail to start, due to instance information is not provided to the job. We can fix this problem by adding a for loop in the script section:
1
2
3
4
5
6
7
8
9
start on (local-filesystems and net-device-up IFACE!=lo)
stop on shutdown
script
for i in `seq 40004002`
do
exec /path/to/my/job
done
end script
With this Upstart job, we do not need to provide instance information:
1
$ sudo start my-job
Therefore, during system restart, the job will initiate automatically.