Open santikris2003 opened 1 year ago
Hi. I've just rebuilt from scratch and can reproduce your problem. I had something similar with another project. While I'm trying to resolve it, you should be able to just use 172.17.0.2 (default port 80, not 8100, ie http://172.17.0.2). Does that work?
Here's something that worked for me.
Bring both your VMs down - in both vagrant directories, do:
vagrant halt
Remove the docker network
docker network ls
Look for the one called vagrant_network_10.50.0.0/24 and then do
docker network rm
Now change this line in the Vagrantfile for both VMs: config.vm.network "private_network", ip: "10.50.0.2" to config.vm.network "private_network", ip: "10.50.0.2", docker_network__attachable: true
Now bring both VMs up again with vagrant up (no need to destroy and rebuild them).
This worked for me. Please let me know if it works for you too, and if so I will update the repo.
I added that line in the Vagrant line , followed your instructions to remove specific network ,still not able connect to web server in container
config.vm.network "private_network", ip: "10.50.0.2",docker_network__attachable: true
$ vagrant halt ==> default: Stopping container... $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES $ docker network ls NETWORK ID NAME DRIVER SCOPE c212cae82946 bridge bridge local 047c32ac87de host host local b912d810b85c none null local 53b92957481d vagrant_network_10.50.0.0/24 bridge local ca0356663527 vagrant_network_192.168.1.0/24 bridge local $ docker network rm 53b92957481d 53b92957481d
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
c212cae82946 bridge bridge local
047c32ac87de host host local
b912d810b85c none null local
ca0356663527 vagrant_network_192.168.1.0/24 bridge local
$ nano Vagrantfile
$ vagrant up --provider docker
Bringing machine 'default' up with 'docker' provider...
==> default: Creating and configuring docker networks...
==> default: Enabling network interfaces...
==> default: Starting container...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
==> default: Machine already provisioned. Run vagrant provision
or use the --provision
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running provisioner: shell...
default: Running: /var/folders/b2/lz3vcdsn7nb229_b8319t45h0000gn/T/vagrant-shell20231007-44233-auyywo.sh
default: Invoking 'systemctl start apache2'.
default: Use 'systemctl status apache2' for more info.
$ vagrant ssh
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 6.1.30-0-virt aarch64)
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fb2d0873c331 mbakereth/vagrant-provider-ubuntu:focal "/usr/sbin/init" 19 hours ago Up About a minute 0.0.0.0:8100->8100/tcp, 127.0.0.1:2222->22/tcp vagrant_default_1696613065
$ docker network ls NETWORK ID NAME DRIVER SCOPE c212cae82946 bridge bridge local 047c32ac87de host host local b912d810b85c none null local 86ad575a0c4e vagrant_network_10.50.0.0/24 bridge local ca0356663527 vagrant_network_192.168.1.0/24 bridge local
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fb2d0873c331 mbakereth/vagrant-provider-ubuntu:focal "/usr/sbin/init" 19 hours ago Up 4 minutes 0.0.0.0:8100->8100/tcp, 127.0.0.1:2222->22/tcp vagrant_default_1696613065
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' vagrant_default_1696613065 172.17.0.2
$ curl -v http://10.50.0.2
$ curl -v http://172.17.0.2
Ah so you can’t get in on the default ip either.
Let’s see if it’s a network issue or a web server issue. Could you try these?
from your Mac:
ping 172.17.0.2
That will determine if it’s a network issue. If the networking is ok you should get responses.
Next vagrant ssh
into the machine and try
curl http://localhost/
If that returns something then the web server is at least running.
If the web server is running you could map port 80 on the vm to a port on the host. Just copy the line that maps port 8100 in the Vagrantfile, changing the guest port to 80 and the host port to a free port, eg 8000. It’s suboptimal as you will have to do the same for the other machine, choosing a different host port, and also map mailcatcher’s port 1080. But at least it will get you going, if the web server is actually running.
Sorry, I don’t have an M1. I have an Intel Mac. I can ask a colleague on Monday to try it again on his M1.
I tried the above steps as you suggested , still cant connect to webserver on the container , you can let me know what you find from the same repro on Mac M1 , I can wait until then
PING 172.17.0.2 (172.17.0.2): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 Request timeout for icmp_seq 2 Request timeout for icmp_seq 3 Request timeout for icmp_seq 4 Request timeout for icmp_seq 5 Request timeout for icmp_seq 6 ^C --- 172.17.0.2 ping statistics --- 8 packets transmitted, 0 packets received, 100.0% packet loss
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 6.1.30-0-virt aarch64)
curl: (7) Failed to connect to localhost port 80 after 6 ms: Couldn't connect to server
$ nano Vagrantfile
$ vagrant halt
==> default: Stopping container...
$ nano Vagrantfile
$ vagrant up --provider docker
Bringing machine 'default' up with 'docker' provider...
==> default: Creating and configuring docker networks...
==> default: Enabling network interfaces...
==> default: Starting container...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Machine already provisioned. Run vagrant provision
or use the --provision
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running provisioner: shell...
default: Running: /var/folders/b2/lz3vcdsn7nb229_b8319t45h0000gn/T/vagrant-shell20231007-61913-eknf47.sh
default: Invoking 'systemctl start apache2'.
default: Use 'systemctl status apache2' for more info.
curl: (7) Failed to connect to localhost port 80 after 8 ms: Couldn't connect to server
^C
^C
Any updates if you were able to test with Mac M1 if the setup is working ?
Hi. I've ask my colleague (sorry I have three colleagues with M1's, two of whom are on holiday, the other fortunately is not). Waiting for his response.
In the meantime, I'm trying to narrow the problem down a bit. I'll create a very simple docker image just to see if the problem is there or Vagrant.
Did you do these two steps?
brew install chipmk/tap/docker-mac-net-connect
sudo brew services start chipmk/tap/docker-mac-net-connect
You could try this:
docker network create --driver bridge nettest
docker run -d -it --name nettest1 --network nettest --mount type=bind,source="$(pwd)",target=/src ubuntu:focal tail -f /dev/null
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nettest1
then ping its IP address. That is just Docker, no Vagrant and nothing special in the container so if that doesn't work, I think it's probably down to docker-mac-netconnect having issues
I tried the above mentioned set of instructions and getting ping timed out , not sure what could the reason $ brew install chipmk/tap/docker-mac-net-connect Warning: chipmk/tap/docker-mac-net-connect v0.1.2 is already installed and up-to-date. To reinstall v0.1.2, run: brew reinstall docker-mac-net-connect
$ sudo brew services start chipmk/tap/docker-mac-net-connect
Password:
Service docker-mac-net-connect
already started, use brew services restart docker-mac-net-connect
to restart.
$ docker network create --driver bridge nettest 93374dfdbf870281055eb338b5904dcee8efc0eb47e2494063cdade5a235580d
$ docker run -d -it --name nettest1 --network nettest --mount type=bind,source="$(pwd)",target=/src ubuntu:focal tail -f /dev/null Unable to find image 'ubuntu:focal' locally focal: Pulling from library/ubuntu 82d728d38b98: Pull complete Digest: sha256:33a5cc25d22c45900796a1aca487ad7a7cb09f09ea00b779e3b2026b4fc2faba Status: Downloaded newer image for ubuntu:focal 3591efec48ede3cd5f865cc0c9bdb43537fbc91c6ae9495e203a09c68fd457bb
$ docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nettest1 172.18.0.2
$ ping 172.18.0.2 PING 172.18.0.2 (172.18.0.2): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 Request timeout for icmp_seq 2 Request timeout for icmp_seq 3 Request timeout for icmp_seq 4 ^C --- 172.18.0.2 ping statistics --- 6 packets transmitted, 0 packets received, 100.0% packet loss
Well at least then it's not a problem with Vagrant. The thing about Docker on Mac and Windows it it runs in its own VM (Hyperkit I think). So to try to access the IP address of a container, it has to be routed through that intermediate VM. That's what docker-mac-net-connect is supposed to do, but evidently isn't.
Apparently Virtualbox now works on M1 and M2. You could try that instead. Destroy the box you have (vagrant destroy), install Virtualbox and start the VMs with the Virtualbox provider instead (vagrant up
without the --provider
).
I tried to install Virtualbox(VirtualBox-7.0.10a-158379-OSX.dmg) on my Mac M1 macOS :Ventura but getting not supported Attached screenshot
They seem to have hidden the M1 binary on their downloads page pretty well! Go to
https://www.virtualbox.org/wiki/Download_Old_Builds_7_0
and download the one called Developer preview for macOS / Arm64 (M1/M2) hosts. This should be the direct link:
Vagrant installation completed for /django-coffeeshop/coffeeshop/vagrant.
Able to do vagrant ssh
$ vagrant ssh Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 6.1.30-0-virt aarch64)
But not able to connect to http://10.50.0.2/ , also tried this
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fb2d0873c331 mbakereth/vagrant-provider-ubuntu:focal "/usr/sbin/init" 13 hours ago Up 11 minutes 0.0.0.0:8100->8100/tcp, 127.0.0.1:2222->22/tcp vagrant_default_1696613065
172.17.0.2
$ curl -v http://172.17.0.2:8100
Trying 172.17.0.2:8100...
connect to 172.17.0.2 port 8100 failed: Operation timed out
Failed to connect to 172.17.0.2 port 8100 after 75006 ms: Couldn't connect to server
Closing connection 0 curl: (28) Failed to connect to 172.17.0.2 port 8100 after 75006 ms: Couldn't connect to server
still not able to connect , please help