<commit_before>---
layout: post
title: Copying files to a container
date: 2019-04-03 03:00:00 +0000
img: "/pro_tip.png"
comments: true
tags:
- colinha
- docker
- container
- containers
- pro tip
- listing
- image
subtitle: Let's learn to copy files into a container

---
***

Esse texto pode ser encontrado também em Portug

***

Sometimes volumes do not work and you have to copy things into the container. Really! You must be wondering, _"How does a technology that everyone uses, doesn’t work?!”_.

Okay, okay, I know this is looking like those stories of "works on my machine" inverted. But let me explain, earlier this year I was working with a temporary computer. Unfortunately, I did not have administrator powers of that computer, which prevented me from doing certain things, including giving Docker permission to share volumes with the Windows file system.

Is worth mentioning that I only discovered how to copy files to a running container because windows have these permission issues.

So, let's go!

## Materials

For this little tutorial, you’ll need:

* A running Docker container
* A file to copy to said Docker containerr
* Basic Docker knowledge

## Finding out the container

Depending on how you started your container you won't know its name, so let's first check it out. Since I work with science and data analysis, it is very common to find myself with a Jupyter container running, this is the one I will use here. To get the name of the container we need to list the containers that are up:

<script src="https://gist.github.com/jtemporal/6ba7e2a2ac369738bb8278ad58993161.js"></script>

In my case this command shows a result like this:

    CONTAINER ID        IMAGE                          NAMES<commit_msg>Update from Forestry.io Jessica Temporal updated _posts/2019-04-03-copying-files-to-a-container.md<commit_after>---
layout: post
title: Copying files to a container
date: 2019-04-03 03:00:00 +0000
img: "/pro_tip.png"
comments: true
tags:
- colinha
- docker
- container
- containers
- pro tip
- listing
- image
subtitle: Let's learn to copy files into a container

---
***

Se preferir [leia esse texto em Português](https://jtemporal.com/copiando-arquivos-para-dentro-do-container/).

***

Sometimes volumes do not work and you have to copy things into the container. Really! You must be wondering, _"How does a technology that everyone uses, doesn’t work?!”_.

Okay, okay, I know this is looking like those stories of "works on my machine" inverted. But let me explain, earlier this year I was working with a temporary computer. Unfortunately, I did not have administrator powers of that computer, which prevented me from doing certain things, including giving Docker permission to share volumes with the Windows file system.

Is worth mentioning that I only discovered how to copy files to a running container because windows have these permission issues.

So, let's go!

## Materials

For this little tutorial, you’ll need:

* A running Docker container
* A file to copy to said Docker containerr
* Basic Docker knowledge

## Finding out the container

Depending on how you started your container you won't know its name, so let's first check it out. Since I work with science and data analysis, it is very common to find myself with a Jupyter container running, this is the one I will use here. To get the name of the container we need to list the containers that are up:

<script src="https://gist.github.com/jtemporal/6ba7e2a2ac369738bb8278ad58993161.js"></script>

In my case this command shows a result like this:

    CONTAINER ID        IMAGE                          NAMES
{'fraction_non_alphanumeric': 0.0619126589275843, 'fraction_numerical': 0.024322830292979547, 'mean_word_length': 3.8971583220568338, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1078972', 'n_tokens_mistral': 1045, 'n_tokens_neox': 946, 'n_words': 520}