rofrano / vagrant-docker-provider

Build a docker image that can be used in vagrant as a development environment
Apache License 2.0
101 stars 51 forks source link

Help needed. #16

Open bayeslearner opened 2 years ago

bayeslearner commented 2 years ago

The documentation mentioned that instead of using docker, vagrant can also support docker-compose as a provider.

compose (boolean) - If true, Vagrant will use docker-compose to manage the lifecycle and configuration of containers. This defaults to false.
compose_configuration (Hash) - Configuration values used for populating the docker-compose.yml file. The value of this Hash is directly merged and written to the docker-compose.yml file allowing customization of non-services items like networks and volumes.

But maybe my understanding is incorrect, maybe it only means internally a docker-compose is used, but if one has multiple containers, they all have to be config-ed separately?
I'm confused and I can't find an example anywhere. You seemed to have looked into this, do you happen to know whether a docker-compose file can be used a provider?

If yes, can one do the following too? use shell provisioner with the containers defined inside the docker-compose file. How to refer those containers by vagrant names? enable ssh in the docker image; use ansible provisoner with the containers defined inside the docker-compse file. use the compose-configuration hash to merge with docker-compose file.

bayeslearner commented 2 years ago

https://www.muisit.nl/vagrant-docker-and-ansible/#page-content

rofrano commented 2 years ago

Hi @bayeslearner, I never noticed that option before. Like you, I cannot find any examples that use it. I will have to play around with it and see what it does.

In the mean time, I have a repo that I use in a Lab in my DevOps course, that has Vagrantfile that spins up 3 Docker containers. One with ansible, and two bare Ubuntu containers. I then teach students to ssh into the ansible container nd use it to configure the other two containers as if they were two remote VM's. Maybe something in the Vagrantfile will give you some ideas because I could have used the Vagrant Ansible plug-in to configure all of the containers automatically (but that would defeat the learning experience of using ansible for my students) ;-)

Here is the lab: https://github.com/nyu-devops/lab-ansible

I will continue to investigate the compose_configuration option of vagrant as time permits.