3

I still try to understand some things with docker helped with portainer but i can't find tuto for:

1 - Persistent data: I would like to run Mariadb container with persistent database. So i would like to add a volume "db" with a mountpoint in my /home/user. Unfortunatly, the mount point is always in /var/lib/docker/volumes etc. How to do that?

2 - Link: assuming i succeed to run the mysql container with persistent database, i would like to link nginx container (with persistent data /home/mountpoint:/data/www) to my mysql container with environment variable (example with docker compose: https://github.com/dadeg/docker-compose-nginx-php7-mysql/blob/master/docker-compose.yml). I notice the network option but i don't think it could help... How to link the container and create template with more environment variable?

Docker-compose could be a better way?

Thank you in advance for any help.

jB

jbo
  • 41
  • 1
  • 5

1 Answers1

1

When you create a volume via Docker or Portainer, by default this volume will be stored in /var/lib/docker/volumes on the host. So that is the defaut and correct behavior.

If you want to bind a volume called db via Portainer, create a volume first. Then go into Containers > Add container > Specify your name/image here > In the volume tab you'll be able to bind the volume you just created to a path in the container.

Now, about your link between Ningx and your database. I recommend that you leverage the DNS of Docker networks here.

First, create a new network (call it my-app for example). Then, deploy both your database and Nginx container inside this network. Docker DNS will automatically give the ability to containers inside the same network to communicate using their container name. So if you've named your database container db and your Nginx container nginx, then you'll be able to ping db from nginx and vice-versa.

Tony
  • 281
  • 3
  • 8