Hvordan nettverket en VirtualBox virtuell maskin med en Docker container?

In order to join the docker container to the same network as the VirtualBox virtual machine, den virtuelle maskin av havnearbeider beholderen må opprettes på samme nettverket.

Den VirtualBox Host-Only Network kjører på nettverk. When creating the default Docker virtual machine ensure that the VirtualBox Host Only CIDR is then all containers that run on this Docker machine will run on the same network. If you already have default Docker Machine then you will have to delete it (see below). The default Docker virtual machine can be created using the following command.

docker-machine create --driver "virtualbox" --virtualbox-cpu-count "4" --virtualbox-disk-size "30000" --virtualbox-host-dns-resolver --virtualbox-hostonly-cidr --virtualbox-hostonly-nictype "82540EM" --virtualbox-memory "4096" default

Once the default Docker machine has been created you can check the ip address with the following command

docker-machine ip

This default virtual machine is now on the VirtualBox Host-Only Network and any containers on the default virtual machine will be able to communicate with other VirtualBox virtual machines using the Host-Only Adapter & the correct network configuration.

The above creates the default Docker machine. You may need to delete the default machine before using the above command to create one. You can delete a default machine with the following command.

 docker-machine rm -f -y default

If you getError removing hostdefault”: open C:\Users\Bish\.docker\machine\machines\default\config.json: The system cannot find the file specified.error then run the following commands:

cd %userprofile%/.docker/machine/machines/default

NUL > config.json

Ignore the access is denied message and reboot. After rebooting retry the remove command.

 docker-machine rm -f -y default