1
00:00:02,250 --> 00:00:04,660
Now this can of course also be used

2
00:00:04,660 --> 00:00:07,300
to download and run it.

3
00:00:07,300 --> 00:00:09,010
And to see this in action,

4
00:00:09,010 --> 00:00:13,290
I'll first of all run Docker image prune-a

5
00:00:13,290 --> 00:00:15,783
to delete all local images.

6
00:00:16,630 --> 00:00:20,720
And once that is done and we've got no images left,

7
00:00:20,720 --> 00:00:23,170
except for this node image,

8
00:00:23,170 --> 00:00:27,280
which is still around because I started this container

9
00:00:27,280 --> 00:00:29,830
based on this node image a couple of minutes ago,

10
00:00:29,830 --> 00:00:32,040
I would have to delete this container first

11
00:00:32,040 --> 00:00:35,100
in order to be able to delete this image

12
00:00:35,100 --> 00:00:37,210
but let's not worry about this now.

13
00:00:37,210 --> 00:00:40,270
The main thing is that all the other images are missing

14
00:00:40,270 --> 00:00:43,040
and with that, we can now use Docker Pull

15
00:00:43,040 --> 00:00:45,770
to download this image.

16
00:00:45,770 --> 00:00:48,210
Now for that first of all I'll log out

17
00:00:48,210 --> 00:00:52,590
to see whether it also works if I'm not logged in anymore,

18
00:00:52,590 --> 00:00:56,060
and then I'll Docker pull academind node-hello-world

19
00:00:57,166 --> 00:01:00,486
which is that image we just pushed.

20
00:01:00,486 --> 00:01:05,236
It then uses that default tag latest and it downloads it.

21
00:01:06,275 --> 00:01:09,707
And then under Docker images, we can see this.

22
00:01:09,707 --> 00:01:12,955
And since this is public, everyone can pull it.

23
00:01:12,955 --> 00:01:15,746
You don't have to be logged in to do that.

24
00:01:15,746 --> 00:01:17,955
That's why I wanted to show this as well.

25
00:01:17,955 --> 00:01:21,387
You need to be logged into Push to this repository,

26
00:01:21,387 --> 00:01:24,115
but everyone is able to pull.

27
00:01:24,115 --> 00:01:27,257
But this now also means that everyone including you

28
00:01:27,257 --> 00:01:28,855
if you're watching this video right now

29
00:01:28,855 --> 00:01:33,855
is able to Docker pull academind/node-hello-world

30
00:01:34,838 --> 00:01:38,507
and you will then have that image on your system.

31
00:01:38,507 --> 00:01:40,546
And of course you can then use that image

32
00:01:40,546 --> 00:01:44,879
to Docker run academind/node-hello-world.

33
00:01:46,395 --> 00:01:47,300
And that's important.

34
00:01:47,300 --> 00:01:49,350
You need to use the full image name

35
00:01:49,350 --> 00:01:51,650
including academind/.

36
00:01:51,650 --> 00:01:54,390
You can now run this and you can now run this

37
00:01:54,390 --> 00:01:57,140
by exposing the right port for example,

38
00:01:57,140 --> 00:02:00,230
and adding that other removal option.

39
00:02:00,230 --> 00:02:02,520
And of course we could also run this in detached mode

40
00:02:02,520 --> 00:02:03,890
if you want it to.

41
00:02:03,890 --> 00:02:06,920
And with that if I reload local hosts 8,000,

42
00:02:06,920 --> 00:02:08,583
I still see this node app.

43
00:02:10,229 --> 00:02:15,230
So with that, I can Docker stop this container

44
00:02:17,540 --> 00:02:20,690
which I started here like this,

45
00:02:20,690 --> 00:02:22,290
and we're done with that.

46
00:02:22,290 --> 00:02:25,310
But that's how you can share your built images

47
00:02:25,310 --> 00:02:30,230
and not just a Docker File with anyone through Docker Hub

48
00:02:30,230 --> 00:02:32,877
and the repositories you manage there.

49
00:02:32,877 --> 00:02:35,210
But Docker Hub has more features,

50
00:02:35,210 --> 00:02:37,310
it can also help us with deployment,

51
00:02:37,310 --> 00:02:38,380
but for the moment,

52
00:02:38,380 --> 00:02:42,040
this is the key feature you have to know

53
00:02:42,040 --> 00:02:46,023
if you plan on sharing your Docker images with anyone else.

54
00:02:46,910 --> 00:02:50,640
Now, a couple of important notes about pulling and running

55
00:02:50,640 --> 00:02:52,890
your remote images.

56
00:02:52,890 --> 00:02:56,220
Docker Pull, when you execute this command

57
00:02:56,220 --> 00:03:01,220
will always pull the latest image of that name

58
00:03:01,270 --> 00:03:04,280
from your container registry.

59
00:03:04,280 --> 00:03:07,580
So if in the meantime, you will rebuild the image

60
00:03:07,580 --> 00:03:10,900
and push an updated image to the registry

61
00:03:10,900 --> 00:03:13,960
the next time you will execute Docker Pull

62
00:03:13,960 --> 00:03:16,103
will fetch that latest image.

63
00:03:17,000 --> 00:03:20,300
Now you could also run Docker Run

64
00:03:20,300 --> 00:03:23,160
without running Docker Pull first.

65
00:03:23,160 --> 00:03:28,160
If Docker Run doesn't find an image locally on your machine,

66
00:03:28,230 --> 00:03:32,060
it will automatically reach out to the container history,

67
00:03:32,060 --> 00:03:33,680
your image name uses

68
00:03:33,680 --> 00:03:36,320
so here in this case, Docker Hub,

69
00:03:36,320 --> 00:03:39,200
and it will check for the image there.

70
00:03:39,200 --> 00:03:41,470
And if it finds an image of that name there

71
00:03:41,470 --> 00:03:44,990
it will use that and pull that automatically.

72
00:03:44,990 --> 00:03:49,510
What Docker Run will not do though, and that's important

73
00:03:49,510 --> 00:03:53,370
is automatically check for updates.

74
00:03:53,370 --> 00:03:55,370
If you have an image locally

75
00:03:55,370 --> 00:03:58,510
because you pulled or ran it before,

76
00:03:58,510 --> 00:04:02,290
then if you run a container again based on an image,

77
00:04:02,290 --> 00:04:05,340
Docker Run will not check if the image

78
00:04:05,340 --> 00:04:07,330
you have locally on your system

79
00:04:07,330 --> 00:04:10,420
is the latest version of that image.

80
00:04:10,420 --> 00:04:12,260
So if in the meantime,

81
00:04:12,260 --> 00:04:17,010
you updated the image and pushed it again to Docker Hub,

82
00:04:17,010 --> 00:04:19,370
just using Docker Run there after

83
00:04:19,370 --> 00:04:23,440
will not give you that latest updated image.

84
00:04:23,440 --> 00:04:27,630
You instead manually need to run Docker Pull

85
00:04:27,630 --> 00:04:29,710
and then the image name first

86
00:04:29,710 --> 00:04:33,070
to ensure that you have that latest image version

87
00:04:33,070 --> 00:04:35,670
and you then execute Docker Run again.

88
00:04:35,670 --> 00:04:38,000
So it automatically pulls images

89
00:04:38,000 --> 00:04:40,730
but not necessarily the latest version

90
00:04:40,730 --> 00:04:44,700
if you already have that image locally on your system,

91
00:04:44,700 --> 00:04:47,303
because you pulled it before already.

