# Storage tmpfs

<figure><img src="https://2056950903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7JJDMtYZqFc5W4Gd6mo1%2Fuploads%2Fe0JvAY28BjcadH4Ta2SQ%2Fimage.png?alt=media&#x26;token=bee29709-13f4-4934-9387-377db14e03bb" alt=""><figcaption></figcaption></figure>

## Ubuntu

Demonstração da execução de container ubuntu com a montagem do volume tmpfs e a perda dos dados após a sua parada:

```bash
$ docker container run -it \
    --mount type=tmpfs,target=/app \
    ubuntu \
    /bin/bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
31e907dcc94a: Already exists
Digest: sha256:8a37d68f4f73ebf3d4efafbcf66379bf3728902a8038616808f04e34a9ab63ee
Status: Downloaded newer image for ubuntu:latest
root@2fec593dfdcd:/# ls
app  boot  etc   lib    media  opt   root  sbin  sys  usr
bin  dev   home  lib64  mnt    proc  run   srv   tmp  var
root@2fec593dfdcd:/# cd app
root@2fec593dfdcd:/app# ls
root@2fec593dfdcd:/app# touch teste1.txt
root@2fec593dfdcd:/app# ls
teste1.txt
root@2fec593dfdcd:/app# exit
exit
$ docker volume ls
DRIVER    VOLUME NAME
$
```

## MySQL

Demonstração da execução de container mysql com a montagem de volume tmpfs e o acesso ao banco de dados enquanto o container estiver em execução:

```bash
$ docker container run -d -p 3306:3306 \
    --tmpfs /var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 \
    mysql
Unable to find image 'mysql:latest' locally
latest: Pulling from library/mysql
6e839ac3722d: Pull complete
ad912193ad5f: Pull complete
25d13d87fd8d: Pull complete
004d383c75ef: Pull complete
6d9bbc82a0b8: Pull complete
81fec07ea550: Pull complete
83357cb2d3a5: Pull complete
8ffe968b82c1: Pull complete
30dfd9a7ed57: Pull complete
35844ae33cbe: Pull complete
```

Acesso ao banco de dados e a criação de uma tabela:

<figure><img src="https://2056950903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7JJDMtYZqFc5W4Gd6mo1%2Fuploads%2FvCc1gGnuseu661jM32rj%2Fimage.png?alt=media&#x26;token=3a6179fe-434e-498e-a433-e5efe5d3e0f0" alt=""><figcaption></figcaption></figure>

Exclusão do container em execução:

```bash
$ docker container ls
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                                  NAMES
b98bf135be30   mysql     "docker-entrypoint.s…"   12 minutes ago   Up 12 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   nostalgic_vaughan
marcelo@Latitude5440:~$ docker container rm -f b98b
b98b
```

Perda do acesso ao banco de dados:

<figure><img src="https://2056950903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7JJDMtYZqFc5W4Gd6mo1%2Fuploads%2F4Tk6FCMYbePXZanP5kuP%2Fimage.png?alt=media&#x26;token=ceee10c1-b943-40ee-bca3-6bc6f1587c68" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
O volume tmpfs não pode ser compartilhado entre outros containeres.
{% endhint %}
