#014 Volumes
Tags: docker, devops, tutorial
Published: 2020-06-16 18:38:36

# Introduction

this is part 14 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.
***
# Download app_014
![app_013](https://dev-to-uploads.s3.amazonaws.com/i/vvdddf48acyxqdwnvfa7.png)

if you follow [part 9](https://dev.to/elkhatibomar/009-dockerfile-113f)

```bash
cd location/DevOpsJourney/app_014/
```
replace location with where you put the DevOpsJourney

if your new go to [part 9](https://dev.to/elkhatibomar/009-dockerfile-113f) and do same steps will download old lecture files and new one.

***

# The Problem

so the problem with our Docker right now is every time we need to make a change for our code we need to rebuild image , is time and space waste , and not a pragmatic way to do.

# Let's see the problem

first let's build our app
```bash
docker image build -t app_014 .
```

![build](https://dev-to-uploads.s3.amazonaws.com/i/yyjoq13fqjflynqr0tow.png)


and let's run our app
```bash
docker run -it app_014
```
![run](https://dev-to-uploads.s3.amazonaws.com/i/9s7tx29ggyhwmg7lefxz.png)

our app will print a message and save a number to a file.txt
let's take a look inside our app

![app](https://dev-to-uploads.s3.amazonaws.com/i/ls23re0u7f2twy1ilyqn.png)

it will save number 12 to a file.txt

let's take a look inside our app folder , as we know docker will create an app folder inside his own image because we asked to do this , check [#009 Dockerfile](https://dev.to/elkhatibomar/009-dockerfile-113f) 
so to access this app folder using interactive shell

![sh](https://dev-to-uploads.s3.amazonaws.com/i/joaixfbq9rapxd2fy4sk.png)

```bash
docker run -it app_014 sh
```
inside the interactive shell
```bash
cat file.txt
```
we can see that 12 is stored
***
# Time to make a change 
let's change 12 in our app.py to 666
first exit our interactive shell
![exit](https://dev-to-uploads.s3.amazonaws.com/i/v09jozt26w0vvi3kszdl.png)
```bash
exit
```
I use vim as my text editor(actually as complete IDE ;D )

let's take a look again inside the container

![sh](https://dev-to-uploads.s3.amazonaws.com/i/joaixfbq9rapxd2fy4sk.png)

```bash
docker run -it app_014 sh
```
inside the interactive shell
```bash
cat file.txt
```
we can see that isn't changed
***

# The fix
we can fix our problem using -v (volume)

```bash
docker run -it --rm --name app_014 -v $PWD:/app app_014
```

$PWD is a default variable in linux it store the home url
in our case , we use in docker alpine which is a linux based distro , /app is the directory we make in Dockerfile to store our app
again let's take a look inside

```bash
docker run -it --rm --name app_014 -v $PWD:/app app_014 sh
```
inside the interactive shell
```bash
cat app.py
```
as we see we got 666 without rebuild our image!

![666](https://dev-to-uploads.s3.amazonaws.com/i/cg19hll62671whbqbxx9.png)

let's try 999

![999](https://dev-to-uploads.s3.amazonaws.com/i/8jtorstzer5mwxq4sfha.png)

see as soon I change my code is got updated inside the image with out rebuild the image.