-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy path04-Dockerhub.Rmd
104 lines (83 loc) · 3.28 KB
/
04-Dockerhub.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
title: "Pushing and Pulling to and from Docker Hub"
output:
dcTemplate::dc_lesson_template:
fig_width: 6
fig_height: 6
highlight: pygments
---
```{r knitr_init, echo = FALSE, cache = FALSE}
library(knitr)
## Global options
options(max.print = "75")
opts_chunk$set(cache = TRUE,
prompt = FALSE,
tidy = TRUE,
comment = "> #",
message = FALSE,
warning = FALSE)
opts_knit$set(width = 75)
```
## Lesson Objectives
- Understanding where images come from
- Pulling a Docker image from Docker Hub
- Pushing a Docker image to Docker Hub
## Getting an image from Docker Hub
[Docker Hub](https://hub.docker.com/) is the place where open Docker images are stored.
When we ran our first image by typing
```{}
docker run --rm -p 8787:8787 rocker/hadleyverse
```
the software first checked if this image is available on your computer and since it wasn't it
downloaded the image from Docker Hub. So getting an image from Docker Hub works sort of automatically.
If you just want to pull the image but not run it, you can also do
```{}
docker pull rocker/hadleyverse
```
## Getting an image to Docker Hub
Imagine you made your own Docker image and would like to share it with the world you can sign up for an
account on https://hub.docker.com/. After verifying your email you are ready to go and upload your first
docker image.
1. Log in on https://hub.docker.com/
2. Click on *Create Repository*.
3. Choose a name (e.g. hadleyverse_gapminder) and a description for your repository and click *Create*.
4. Log into the Docker Hub from the command line
```{}
docker login --username=yourhubusername [email protected]
```
just with your own user name and email that you used for the account.
Enter your password when prompted. If everything worked you will get a message similar to
```{}
WARNING: login credentials saved in /home/username/.docker/config.json
Login Succeeded
```
5. Check the image ID using
```{}
docker images
```
and what you will see will be similar to
```{}
REPOSITORY TAG IMAGE ID CREATED SIZE
hadleyverse_gapminder_addpackage latest 95fc956d3a73 2 days ago 2.902 GB
hadleyverse_gapminder latest 6a131c8f7c2b 2 days ago 2.87 GB
rocker/hadleyverse latest 2a039f703dad 3 days ago 2.869 GB
```
and tag your image
```{}
docker tag 6a131c8f7c2b yourhubusername/hadleyverse_gapminder:firsttry
```
The number must match the image ID and `:firsttry` is the tag.
<!--- TODO: Any suggestions on which tag to use? Are there good practices here? -->
6. Push your image to the repository you created
```{}
docker push yourhubusername/hadleyverse_gapminder
```
Your image is now available for everyone to use.
## Challenge Questions
- Download your partner's image. How did that compare speed-wise to downloading
the hadleyverse image the first time?
- Browse Docker Hub for interesting images. What could be useful to you?
- Discuss the pros and cons of using Docker images from someone you don't
know with your neighbour.
Next: Go to [Lesson 05 Dockerfiles](05-dockerfiles.html) or back to the
[main page](http://ropenscilabs.github.io/r-docker-tutorial/).