Skip to content

Commit

Permalink
edits and clarifications in module 4
Browse files Browse the repository at this point in the history
  • Loading branch information
obigriffith committed Dec 13, 2024
1 parent 288a03d commit ff45146
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions 04-using-volumes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ So how do we get files we need onto a container we are using?

There are a few options:

- We could run our container and within that we could download the files we need from online! For example we could `git clone` files from a repository or otherwise `wget` or `curl` files that are stored.
- We could `COPY` a file on to the docker image when we are building it (more on this next chapter). But this strategy we want to be careful with for two reasons:
- We don't want our image to be too big. so this strategy can be fine if the file is small and something we know will always be needed for any use of the container.
- We could run our container and within that we could download the files we need from online! For example we could `git clone` files from a repository or otherwise `wget` or `curl` files that are stored online somewhere.
- We could `COPY` a file on to the docker image when we are building it (more on this next chapter). But we want to be careful with this strategy for two reasons:
- We don't want our image to be too big. So, this strategy can be fine if the file is small and something we know will always be needed for any use of the container.
- We DEFINITELY need to avoid ever having protected data on images that are shared. NEVER put protected data on images that we are sharing -- more on this later too.
- Lastly we can add a `volume` of files that are local to our computer. We'll dive into this strategy in this chapter. This will probably be a common way you'll use to get access to files on your container.

- Lastly we can add a `volume` of files that are local to our computer. We'll dive into this strategy in this chapter. This will probably be the most common way you'll use to get access to files on your container.

What is a volume? A volume is a folder, likely from your computer, that can be accessed by your container.

Expand All @@ -40,21 +39,21 @@ xaringanExtra::style_panelset_tabs(font_family = "inherit")

### Docker

Our container is separate from our computer so if we want to use a file we have to attach it using a "volume".
Our container is separate from our computer so if we want to use a file from our computer we have to attach it using a "volume".

##### Step 1: Let’s add our containers-for-scientists-sandbox files

Let's point a volume to our workshop files so we have them on our container.

We can specify a particular file path on our computer or give it `$PWD` Then optionally we can give a `:` and a file path we'd like this to be stored on on the container. Otherwise it will be stored at the absolute top of the container.
We can specify a particular file path on our computer or give it `$PWD`. Then optionally we can give a `:` and a file path where we'd like it to be stored on the container. Otherwise it will be stored at the absolute top of the container. Note that `$PWD` is a special environment variable that stores the absolute path of the current working directory. You will need to be in the `containers-for-scientists-sandbox-main` for this to work.

```{r, out.width = "100%", echo = FALSE}
ottrpal::include_slide("https://docs.google.com/presentation/d/1T5Lfei2UVou9b0qaUCrWXmkcIwAao-UcN4pHMPEE4CY/edit#slide=id.g30a4ed49e59_0_1128")
```

<input type="checkbox"> Now we can run:
```
docker run -v $pwd:/home cansav09/practice-image:1
docker run -v $PWD:/home cansav09/practice-image:1
```
If you have a windows machine you may have to run this variant instead. This version has a different `${}` around the `pwd` part.
```
Expand All @@ -69,7 +68,8 @@ ottrpal::include_slide("https://docs.google.com/presentation/d/1T5Lfei2UVou9b0qa

#### Step 2: Retry calling the script

<input type="checkbox"> Now we can run the following command but we will have to run `docker ps` and get the container ID we need to put here.
<input type="checkbox"> Now we can run the following command but we will have to run `docker ps` or `docker container ls` and get the container ID we need to put here.

```
docker exec -it <REPLACE_WITH_CONTAINER_ID> bash /home/run_analysis.sh
```
Expand Down

0 comments on commit ff45146

Please sign in to comment.