'Vagrant set docker container network to host mode
I would like to launch a vagrant VM with a Docker provisioner, and set the network type of a docker container to host.
Is it something that is feasible?
My actual config for this container is below:
config.ssh.insert_key = false
config.vm.define "dev", primary: true do |app|
app.vm.provider "docker" do |d|
d.image = "allansimon/allan-docker-dev-python"
d.name = "#{PROJECT}_dev"
d.has_ssh = true
d.env = DOCKER_ENV
d.link "#{PROJECT}_db:db"
d.ports = ["0.0.0.0:7011:8000"]
end
app.ssh.username = "vagrant"
# so that we can git clone from within the docker
app.vm.provision "file", source: "~/.ssh/id_rsa", destination: ".ssh/id_rsa"
app.vm.provision "install_everything", type: "shell", privileged: false do |s|
# needed to pass DB credentials for running the alembic migration
s.env = DOCKER_ENV
s.inline = "
set -e
cd /vagrant
python3.8 -m venv /tmp/venv
source /tmp/venv/bin/activate
pip install --upgrade pip
pip install wheel
pip install -r requirements/dev.txt
./manage.py migrate
echo 'source /tmp/venv/bin/activate' >> /home/vagrant/.zshrc
echo 'cd /vagrant' >> /home/vagrant/.zshrc
"
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
