# Edit text file inside docker

**URL:** <https://forums.docker.com/t/edit-text-file-inside-docker/45219>\
**Category:** Docker Desktop\
**Tags:** docker, macos\
**Created:** [January 26, 2018, 12:23pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219 "2018-01-26T12:23:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucacasa](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@lucacasa](https://forums.docker.com/u/lucacasa)\
**Post date:** [January 26, 2018, 12:23pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/1 "2018-01-26T12:23:46Z")

</div>

Hi everybody!  
I am very new to docker, as a matter of fact I stumbled upon it because I am using openFOAM for mac.  
I am having some troubles editing text file inside of the docker, which is an action I need to perform pretty often when working with openFOAM.  
I usually start openFOAM, which I suppose works inside a docker container. Once I do, I log in as “ofuser…” and I can navigate through my files in Mac. The problem is that when I try to use nano to edit files i receive a:

bash: nano: command not found

I tried to do a “apt-get install nano” but i get this instead:

bash: apt-get: command not found

I also tried to use the “cat” function, but it’s not really what I am looking for.  
At the moment I’m using two different terminal windows, one logged in the docker the other as mac user. The problem is that this way I have to navigate to the folders twice, which slows down the process considerably.

Is there a way to install nano (or any other text editor) inside the docker?  
Thanks 🙂

---

<div class="post-metadata">

**Author:** ![sdetweil](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@sdetweil](https://forums.docker.com/u/sdetweil)\
**Post date:** [January 26, 2018, 12:55pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/2 "2018-01-26T12:55:24Z")

</div>

i installed the openFoam image, see [https://openfoam.org/download/5-0-linux/](https://openfoam.org/download/5-0-linux/)

and nano is available without problem.

the mac instructions load the same ubuntu based image  
[https://hub.docker.com/r/openfoam/openfoam5-paraview54/](https://hub.docker.com/r/openfoam/openfoam5-paraview54/)

---

<div class="post-metadata">

**Author:** ![lucacasa](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@lucacasa](https://forums.docker.com/u/lucacasa)\
**Post date:** [January 26, 2018, 1:10pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/3 "2018-01-26T13:10:50Z")

</div>

I followed the instructions from the official open foam page, not the foundation.  
I’ll try your solution right away and i’ll let you know.  
Thanks 🙂

---

<div class="post-metadata">

**Author:** ![sdetweil](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@sdetweil](https://forums.docker.com/u/sdetweil)\
**Post date:** [January 26, 2018, 1:16pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/4 "2018-01-26T13:16:19Z")

</div>

i searched dockerhub for images, and not knowing anything, I picked one… that sent me to the link I posted

---

<div class="post-metadata">

**Author:** ![dairlab](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/dairlab/32/14883_2.png) [@dairlab](https://forums.docker.com/u/dairlab)\
**Post date:** [January 26, 2018, 2:13pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/5 "2018-01-26T14:13:23Z")

</div>

Have you tried this command  
cat /etc/\*-release  
may not be Ubuntu base image,

many new application containers have switched to Alpine Linux their package management tool is apk install …

also vi or vim are probably there…

---

<div class="post-metadata">

**Author:** ![lucacasa](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@lucacasa](https://forums.docker.com/u/lucacasa)\
**Post date:** [January 26, 2018, 2:23pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/6 "2018-01-26T14:23:42Z")

</div>

now I have nano, but apparently I have lost access to my home folder, which is kind of a bummer. Somtimes navigating through many folders through terminal is a bit painful (to me) and i’d rather do that via finder. Also it happens at times that I might just wanna have a look at a file without having to go into the container through terminal…  
Do you know of a way to use your home folder inside the container?

---

<div class="post-metadata">

**Author:** ![sdetweil](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@sdetweil](https://forums.docker.com/u/sdetweil)\
**Post date:** [January 26, 2018, 2:25pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/7 "2018-01-26T14:25:32Z")

</div>

> [@lucacasa](#):
>
> Do you know of a way to use your home folder inside the container?

what do you mean home folder?

the docker HOST file system is hidden from the container, unless some part of it is mounted as a container volume.

---

<div class="post-metadata">

**Author:** ![lucacasa](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@lucacasa](https://forums.docker.com/u/lucacasa)\
**Post date:** [January 26, 2018, 2:28pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/8 "2018-01-26T14:28:51Z")

</div>

if i insert that command this is what i get:

CentOS Linux release 7.3.1611 (Core)  
NAME="CentOS Linux"  
VERSION="7 (Core)"  
ID="centos"  
ID\_LIKE="rhel fedora"  
VERSION\_ID="7"  
PRETTY\_NAME="CentOS Linux 7 (Core)"  
ANSI\_COLOR="0;31"  
CPE\_NAME="cpe:/o:centos:centos:7"  
HOME\_URL="[https://www.centos.org/](https://www.centos.org/)"  
BUG\_REPORT\_URL=“[https://bugs.centos.org/](https://bugs.centos.org/)”

CENTOS\_MANTISBT\_PROJECT="CentOS-7"  
CENTOS\_MANTISBT\_PROJECT\_VERSION="7"  
REDHAT\_SUPPORT\_PRODUCT="centos"  
REDHAT\_SUPPORT\_PRODUCT\_VERSION=“7”

CentOS Linux release 7.3.1611 (Core)  
CentOS Linux release 7.3.1611 (Core)

apparently it’s running a fedora. I’ll try to install it following fedora instructions 🙂

---

<div class="post-metadata">

**Author:** ![lucacasa](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@lucacasa](https://forums.docker.com/u/lucacasa)\
**Post date:** [January 26, 2018, 2:31pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/9 "2018-01-26T14:31:13Z")

</div>

using the version of OpenFOAM on the [https://www.openfoam.com/](https://www.openfoam.com/) it’s still possible to access my /Users/MyName folder. With the version from openfoam foundation it is not. I was wondering if there was a way to access that folder… I don’t know if it is any more clear now…

---

<div class="post-metadata">

**Author:** ![sdetweil](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@sdetweil](https://forums.docker.com/u/sdetweil)\
**Post date:** [January 26, 2018, 2:32pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/10 "2018-01-26T14:32:09Z")

</div>

i have no idea how they did that

---

<div class="post-metadata">

**Author:** ![dairlab](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/dairlab/32/14883_2.png) [@dairlab](https://forums.docker.com/u/dairlab)\
**Post date:** [January 26, 2018, 2:32pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/11 "2018-01-26T14:32:42Z")

</div>

The -v option allows you to map folder in your container with a folder on you PC here is an example docker run command.  
docker run --name containername -d -it -v ~/PCdir/:/Containerdir containername /bin/zsh you can then edit files on your pc and have the changes saved in the container…

---

<div class="post-metadata">

**Author:** ![lucacasa](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@lucacasa](https://forums.docker.com/u/lucacasa)\
**Post date:** [January 26, 2018, 2:47pm UTC](https://forums.docker.com/t/edit-text-file-inside-docker/45219/12 "2018-01-26T14:47:56Z")

</div>

In the end the problem was that I was running a version of Fedora, not Ubuntu. Entering the docker as root and using yum, allowed me finally to install nano. In case someone happens to have the same issue this is how to:

1. run your container
2. in a separate terminal window use this: docker exec -it bash
3. now run: yum -y install nano

As for accessing the home folder from my second container, I’ll try to meddle with it for a while and see if I manage to do it.

Thanks to both of you! 😃
