Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't finish to configure and enable network interfaces when use both public network and docker #7458

Closed
yukihiko-shinoda opened this issue Jun 16, 2016 · 12 comments · Fixed by #7866
Assignees
Milestone

Comments

@yukihiko-shinoda
Copy link

Vagrant version

$ vagrant -v
Vagrant 1.8.4

Host operating system

Windows 10 Pro x64

Guest operating system

CentOS6.7(image: bento v.2.2.7)
https://atlas.hashicorp.com/bento/boxes/centos-6.7

Vagrantfile

VAGRANTFILE_API_VERSION_NO = "2"
Dotenv.load

Vagrant.configure(VAGRANTFILE_API_VERSION_NO) do |config|
  config.vm.box = "CentOS6-7"
  config.vm.boot_timeout = 5000
  config.vm.box_url = "https://atlas.hashicorp.com/bento/boxes/centos-6.7"

  config.vm.network "public_network"

  config.vm.synced_folder "./share", "/root/share", :create => true

  config.vm.provision "docker"
end

Debug output

https://gist.github.com/yukihiko-shinoda/4d4731a595f8af6982f2b8ef5849dd09

Expected behavior

Successfully vagrant up.

Actual behavior

Can't finish to Configure and enable network interfaces.

==> default: Attempting graceful shutdown of VM...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> 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: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Configuring and enabling network interfaces...

Steps to reproduce

1.Prepare Vagrantfile which use both config.vm.network "public_network" and config.vm.provision "docker"
2.vagrant up
3.vagrant halt && vagrant up

  • It works either public network or docker is unavailable.
  • We couldn't avoid this issue by manual docker install.
@yukihiko-shinoda yukihiko-shinoda changed the title can't finish to configure and enable network interfaces when use both public network and docker Can't finish to configure and enable network interfaces when use both public network and docker Jun 16, 2016
@sethvargo
Copy link
Contributor

Hi @yukihiko-shinoda,

I just tried to reproduce this issue and I am unable to do so using the bento/centos-6.7:

Vagrant.configure(2) do |config|
  config.vm.box = "bento/centos-6.7"
  config.vm.network "public_network"
  config.vm.provision "docker"
end

output:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-6.7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-6.7' is up to date...
==> default: Setting the name of the VM: test_default_1466066398889_74617
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
1) en0: Wi-Fi (AirPort)
2) en1: Thunderbolt 1
3) en2: Thunderbolt 2
4) p2p0
5) awdl0
6) bridge0
7) vmnet2
==> default: When choosing an interface, it is usually the one that is
==> default: being used to connect to the internet.
    default: Which interface should the network bridge to? 1
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> 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: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/sethvargo/Desktop/test
==> default: Running provisioner: docker...

Can you please make sure you have the latest version of that centos box? I know there were some issues early on with guest additions for that particular box, but they have since been fixed.

@yukihiko-shinoda
Copy link
Author

Hi, @sethvargo,

Thank you for your reply.
I tried to run following shell by using git bush with your posted Vagrantfile.
But, still can't finish to configure and enable network interfaces.

First time "vagrant up" was succeed.
This issue happen when "vagrant halt && vagrant up"

#!/bin/bash -eux
vagrant box remove bento/centos-6.7
vagrant box list
vagrant plugin update vagrant-vbguest
vagrant plugin list
vagrant global-status --prune
vagrant global-status
vagrant up
vagrant halt
vagrant up
$ ./up_vagrant.sh
+ vagrant box remove bento/centos-6.7
Removing box 'bento/centos-6.7' (v2.2.7) with provider 'virtualbox'...
+ vagrant box list
There are no installed boxes! Use `vagrant box add` to add some
+ vagrant plugin update vagrant-vbguest
Updating plugins: vagrant-vbguest. This may take a few minutes...
All plugins are up to date.
+ vagrant plugin list
dotenv (2.1.1)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.5)
vagrant-vbguest (0.12.0)
+ vagrant global-status --prune
id       name   provider state  directory
--------------------------------------------------------------------
There are no active Vagrant environments on this computer! Or,
you haven't destroyed and recreated Vagrant environments that were
started with an older version of Vagrant.
+ vagrant global-status
id       name   provider state  directory
--------------------------------------------------------------------
There are no active Vagrant environments on this computer! Or,
you haven't destroyed and recreated Vagrant environments that were
started with an older version of Vagrant.
+ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'bento/centos-6.7' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'bento/centos-6.7'
    default: URL: https://atlas.hashicorp.com/bento/centos-6.7
==> default: Adding box 'bento/centos-6.7' (v2.2.7) for provider: virtualbox
    default: Downloading: https://atlas.hashicorp.com/bento/boxes/centos-6.7/versions/2.2.7/providers/virtualbox.box
    default:
==> default: Successfully added box 'bento/centos-6.7' (v2.2.7) for 'virtualbox'!
==> default: Importing base box 'bento/centos-6.7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-6.7' is up to date...
==> default: Setting the name of the VM: vagrant-bug_default_1466083351434_95024
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> 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: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
[default] GuestAdditions 5.0.20 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/shinoda/workspace/vagrant-bug
==> default: Running provisioner: docker...
    default: Installing Docker onto machine...
+ vagrant halt
==> default: Attempting graceful shutdown of VM...
+ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/centos-6.7' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> 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: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
[default] No installation found.
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Package binutils-2.20.51.0.2-5.44.el6.x86_64 already installed and latest version
Package 1:make-3.81-23.el6.x86_64 already installed and latest version
Package bzip2-1.0.5-7.el6_0.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: cpp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-17.el6.x86_64
---> Package kernel-devel.x86_64 0:2.6.32-642.1.1.el6 will be installed
---> Package perl.x86_64 4:5.10.1-141.el6_7.1 will be installed
--> Processing Dependency: perl-libs = 4:5.10.1-141.el6_7.1 for package: 4:perl-5.10.1-141.el6_7.1.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.10.1-141.el6_7.1.x86_64
--> Processing Dependency: perl(version) for package: 4:perl-5.10.1-141.el6_7.1.x86_64
--> Processing Dependency: perl(Pod::Simple) for package: 4:perl-5.10.1-141.el6_7.1.x86_64
--> Processing Dependency: perl(Module::Pluggable) for package: 4:perl-5.10.1-141.el6_7.1.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.10.1-141.el6_7.1.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.4.7-17.el6 will be installed
---> Package glibc-devel.x86_64 0:2.12-1.192.el6 will be installed
--> Processing Dependency: glibc-headers = 2.12-1.192.el6 for package: glibc-devel-2.12-1.192.el6.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.192.el6.x86_64
---> Package perl-Module-Pluggable.x86_64 1:3.90-141.el6_7.1 will be installed
---> Package perl-Pod-Simple.x86_64 1:3.13-141.el6_7.1 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64
---> Package perl-libs.x86_64 4:5.10.1-141.el6_7.1 will be installed
---> Package perl-version.x86_64 3:0.77-141.el6_7.1 will be installed
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.12-1.192.el6 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.192.el6.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.192.el6.x86_64
---> Package perl-Pod-Escapes.x86_64 1:1.04-141.el6_7.1 will be installed
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.32-642.1.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                  Arch      Version                    Repository  Size
================================================================================
Installing:
 gcc                      x86_64    4.4.7-17.el6               base        10 M
 kernel-devel             x86_64    2.6.32-642.1.1.el6         updates     11 M
 perl                     x86_64    4:5.10.1-141.el6_7.1       base        10 M
Installing for dependencies:
 cpp                      x86_64    4.4.7-17.el6               base       3.7 M
 glibc-devel              x86_64    2.12-1.192.el6             base       988 k
 glibc-headers            x86_64    2.12-1.192.el6             base       617 k
 kernel-headers           x86_64    2.6.32-642.1.1.el6         updates    4.4 M
 perl-Module-Pluggable    x86_64    1:3.90-141.el6_7.1         base        40 k
 perl-Pod-Escapes         x86_64    1:1.04-141.el6_7.1         base        33 k
 perl-Pod-Simple          x86_64    1:3.13-141.el6_7.1         base       213 k
 perl-libs                x86_64    4:5.10.1-141.el6_7.1       base       579 k
 perl-version             x86_64    3:0.77-141.el6_7.1         base        52 k

Transaction Summary
================================================================================
Install      12 Package(s)

Total download size: 41 M
Installed size: 95 M
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           1.2 MB/s |  41 MB     00:34
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 1:perl-Pod-Escapes-1.04-141.el6_7.1.x86_64                  1/12
  Installing : 1:perl-Module-Pluggable-3.90-141.el6_7.1.x86_64             2/12
  Installing : 3:perl-version-0.77-141.el6_7.1.x86_64                      3/12
  Installing : 4:perl-libs-5.10.1-141.el6_7.1.x86_64                       4/12
  Installing : 1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64                   5/12
  Installing : 4:perl-5.10.1-141.el6_7.1.x86_64                            6/12
  Installing : kernel-headers-2.6.32-642.1.1.el6.x86_64                    7/12
  Installing : glibc-headers-2.12-1.192.el6.x86_64                         8/12
  Installing : glibc-devel-2.12-1.192.el6.x86_64                           9/12
  Installing : cpp-4.4.7-17.el6.x86_64                                    10/12
  Installing : gcc-4.4.7-17.el6.x86_64                                    11/12
  Installing : kernel-devel-2.6.32-642.1.1.el6.x86_64                     12/12
  Verifying  : glibc-devel-2.12-1.192.el6.x86_64                           1/12
  Verifying  : 1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64                   2/12
  Verifying  : glibc-headers-2.12-1.192.el6.x86_64                         3/12
  Verifying  : cpp-4.4.7-17.el6.x86_64                                     4/12
  Verifying  : 1:perl-Module-Pluggable-3.90-141.el6_7.1.x86_64             5/12
  Verifying  : gcc-4.4.7-17.el6.x86_64                                     6/12
  Verifying  : 1:perl-Pod-Escapes-1.04-141.el6_7.1.x86_64                  7/12
  Verifying  : kernel-headers-2.6.32-642.1.1.el6.x86_64                    8/12
  Verifying  : 3:perl-version-0.77-141.el6_7.1.x86_64                      9/12
  Verifying  : 4:perl-libs-5.10.1-141.el6_7.1.x86_64                      10/12
  Verifying  : 4:perl-5.10.1-141.el6_7.1.x86_64                           11/12
  Verifying  : kernel-devel-2.6.32-642.1.1.el6.x86_64                     12/12

Installed:
  gcc.x86_64 0:4.4.7-17.el6          kernel-devel.x86_64 0:2.6.32-642.1.1.el6
  perl.x86_64 4:5.10.1-141.el6_7.1

Dependency Installed:
  cpp.x86_64 0:4.4.7-17.el6
  glibc-devel.x86_64 0:2.12-1.192.el6
  glibc-headers.x86_64 0:2.12-1.192.el6
  kernel-headers.x86_64 0:2.6.32-642.1.1.el6
  perl-Module-Pluggable.x86_64 1:3.90-141.el6_7.1
  perl-Pod-Escapes.x86_64 1:1.04-141.el6_7.1
  perl-Pod-Simple.x86_64 1:3.13-141.el6_7.1
  perl-libs.x86_64 4:5.10.1-141.el6_7.1
  perl-version.x86_64 3:0.77-141.el6_7.1

Complete!
Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 5.0.20 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.20 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.20 of VirtualBox Guest Additions...
Stopping VirtualBox Additions [  OK  ]
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module[  OK  ]
Building the shared folder support module[  OK  ]
Building the graphics driver module[  OK  ]
Doing non-kernel setup of the Guest Additions[  OK  ]
Starting the VirtualBox Guest Additions Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
[  OK  ]
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...

Debug output

https://gist.github.com/yukihiko-shinoda/9e7f28efa1102089b9b20b1e429821ee

@yukihiko-shinoda
Copy link
Author

I found.

Vagrant was updating eth0 setting.

/sbin/ifdown 'eth0' || true

# Move new config into place
mv '/tmp/vagrant-network-entry-eth0-1466267728-0' '/etc/sysconfig/network-scripts/ifcfg-eth0'

# Bring the interface up
ARPCHECK=no /sbin/ifup 'eth0'
 (sudo=true)
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...

Cause is that network bridge "docker0" is created when docker is installed.

 INFO ssh: Execute: ifconfig -a | grep -o ^[0-9a-z]* | grep -v '^lo' (sudo=true)
DEBUG ssh: stdout: docker0
eth0
eth1

But vagrant can't detect "docker0"

 INFO network: Determining network adapters required for high-level configuration...
 INFO network:  -- Slot 2: bridged
 INFO network: Determining adapters and compiling network configuration...
 INFO network: Network slot 1. Type: nat.
DEBUG network: Normalized configuration: {:auto_config=>false, :adapter=>1}
DEBUG network: Adapter configuration: {:adapter=>1, :type=>:nat}
 INFO network: Network slot 2. Type: bridged.

At first time of "vagrant up", "Configuring and enabling network interfaces..." task run before docker install.
So,
First time "vagrant up" was succeed.
This issue happen when "vagrant halt && vagrant up".

@azusa
Copy link

azusa commented Jul 5, 2016

I had same problem with Docker when "vagrant halt && vagrant up":
environment below:

  • Vagrant 1.8.4
  • VirtualBox 5.0.24
  • Host OS : OS X Yosemite 10.10.5
  • Guest OS: CentOS release 6.8 (Final) (Original Box)

@mikeatlas
Copy link

mikeatlas commented Jul 7, 2016

I've also hit a similar error, but rather than a halted CentOS guest with Docker installed, I am using a bento/centos6.8 (hand-built using packer) box that I installed Docker on and re-packaged, since provisioning Docker takes quite awhile and I thought it would be a good step to not repeat, since I destroy running instances between usages (instead of halting).

I see the same issue and log output as described by @yukihiko-shinoda.

To confirm it is the same problem, I went back to using the base bento/centos6.8 (packer-built) without Docker already provisioned, and was able to get past the hung step of "Configuring and enabling network interfaces...".

@mikeatlas
Copy link

mikeatlas commented Jul 7, 2016

For me, the workaround was to create a new base box with Docker installed, but disabled on startup, and the docker0 bridge deleted:

sudo yum install bridge-utils -y # needed to use the brctl command below
sudo chkconfig docker off # disable docker on startup
sudo service docker stop # stop docker service
sudo ifconfig docker0 down # turn off docker0 interface
sudo brctl delbr docker0 # delete docker0 bridge

From here, I cut a package of the box. Then, as a script command in my Vagrantfile, I make sure to start Docker when I start this box:

config.vm.provision "shell", inline: "sudo service docker start"

Starting the Docker service recreates the docker0 bridge.

This won't help with the issue of vagrant halt though.

@fgerards
Copy link

any news on this one ?
I can confirm this behaviour with:

  • vagrant 1.86 on Windows host
  • virtualbox 5.1.6
  • bento/centOS 7.2 guest with docker installed

@wei-ding
Copy link

I can confirm this issue with:

  • vagrant 1.8.6 on Mac OSX Sierra
  • VirtualBox 5.1.6
  • bento/centos 6 guest with docker service started, public network and private network are enabled.

Linux, and Windows host are fine.

@chrisroberts chrisroberts added this to the 1.8.7 milestone Sep 30, 2016
@chrisroberts chrisroberts self-assigned this Sep 30, 2016
@chrisroberts
Copy link
Member

Checking if #7848 might resolve this.

@theimpostor
Copy link

I am having this issue as well with:

  • Vagrant 1.8.6 on Windows 10 x64
  • VirtualBox 5.1.6
  • bento/ubuntu-16.04
  • config.vm.network "private_network", type: "dhcp"
  • config.vm.provision "docker"

The second time I run 'vagrant up', vagrant gets stuck at 'Configuring and enabling network interfaces' for perhaps a minute. After that, it appears to proceed normally and I am able to log into the guest. I don't recall experiencing this issue with Vagrant 1.8.5.

@chrisroberts
Copy link
Member

Fixed by: #7866

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants