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

  • DO NOT try to change the volumes directory unless you know what you're doing and have a very good reason to do so, beyond "personal preference". – Michael Hampton Jan 19 '17 at 20:32
  • Thank you Michael for your answer. Actually, i would like to externalize the data locally to simplify reinstall. – jbo Jan 19 '17 at 21:18
  • So mount your external storage there. – Michael Hampton Jan 19 '17 at 22:36
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.