How does docker run on osx, does it use vagrant? - macos

I use an older model MB Air and running vagrant is very resource intensive for me.
When using docker on OSX, does it just use vagrant behind the scenes to run my docker instance on ubuntu?

In contrast to the deprecated Docker Toolbox (which also runs on MacOS), recent versions of Docker for Mac do not use VirtualBox, but rather HyperKit, a native MacOS hypervisor, which is built on xhyve. In comparison to VirtualBox, HyperKit claims to be more lightweight.
Also consider the official documentation on the differences and interna of Docker Toolbox and Docker for Mac (emphasis mine):
Docker for Mac is a Mac native application, that you install in /Applications. [...]
Here are some key points to know about Docker for Mac before you get started:
Docker for Mac does not use VirtualBox, but rather HyperKit, a lightweight macOS virtualization solution built on top of Hypervisor.framework in macOS 10.10 Yosemite and higher. [...]
The Docker for Mac application does not use docker-machine to provision that VM; but rather creates and manages it directly.
At installation time, Docker for Mac provisions an HyperKit VM based on Alpine Linux, running Docker Engine. It exposes the docker API on a socket in /var/run/docker.sock. Since this is the default location where docker will look if no environment variables are set, you can start using docker and docker-compose without setting any environment variables.
[...]
With Docker for Mac, you get only one VM, and you don’t manage it. It is managed by the Docker for Mac application, which includes autoupdate to update the client and server versions of Docker.

It doesn't use Vagrant, but it there is underlying VirtualBox machine similar to what Vagrant uses. Things might be slightly better with Docker because the docker VM is very slimmed down version. And you can pack multiple images into that VM in more efficient manner, because they will be using the same kernel and IO layers.
Also, note that with both Vagrant and Docker you can use AWS or similar cloud things to actually run your images.

Related

What is the recommended way to develop docker containers for Linux on Windows?

Background
I am developing a Spring Boot application that will be deployed on Linux Redhat.
As this is a Java application, I can develop on Windows 10 and this is my preference.
To simplify deployment, I have dockerized the application.
Objectives
I would like to test the container on my Windows 10 development computer:
Without installing a VM
Without using Hyper V as a VM.
Without WSL 2.0 (WSL 1.0 can be used)
I need to create a volume so that data written by the container can be accessed on the Windows host during and after the container runs.
The scripts I write to load and run the docker should be as similar as possible as those I will use to deploy on the target Linux Redhat server.
What I have tried
I have installed Docker for Windows on my Windows PC and followed the documentation to allow me to run docker in WSL 1.0.
There are a number of tweaks that need to be done to make this work, and I am still not able to configure a volume to meet my requirement.
Curiously, I happened to try to run the container using docker on from a Windows command prompt and it seems to run too. (though volumes still do not work here either).
This surprised me because I thought that a Linux image can only be loaded into a Linux OS as docker does not run the container in a VM.
My questions
Can I indeed test my Linux container using the Windows prompt or may I run into issues down the road? (issues meaning differences in deployment and run time behavior compared to deployment and running on the Linux target machine).
If a Linux container can run from the Windows prompt, do I even need WSL to run the docker on my windows PC?
What are the advantages, if any, of using WSL to test and test the container in development considering the fact that docker on WSL 1.0 seems to require a little work to get running "flawlessly" on Windows?

Can I run Windows containers on Docker Desktop for Mac? [duplicate]

This question already has answers here:
How can I run a docker windows container on osx?
(3 answers)
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
I want to be able to run Windows Docker Containers on my Mac, it seems this was sort of supported using Docker Toolbox
How can I run a docker windows container on osx?
But it seems that this is now deprecated and we should be using Docker Desktop now.
Docker Desktop has a better and New Hypervisor called HyperKit instead of Virtual Box https://docs.docker.com/docker-for-mac/docker-toolbox/
Docker toolbox allowed starting Windows Containers using VirtualBox, so not sure if that mean's that this is still possible?
I have found a reference to putting Docker Desktop into "Windows Container Mode" here https://www.clearpeople.com/insights/blog/2018/june/sitecore-demo-in-a-docker-container
But I cannot find anywhere to enable this, any help or insight would be very much appreciated.
There is a related question here How can I run a docker windows container on osx? but it's so old that is irrelevant and should not be a reason to lock this question.
Docker only runs natively on Linux machines because it needs Linux kernel features called namespaces and control groups. Docker containers are built from cut down Linux distributions.
The original solution to running Docker on OS X and Windows was Docker Toolkit. This was actually a Linux virtual machine running in the VirtualBox Hypervisor. The VM had Docker installed and could run containers.
Docker Desktop for Mac still makes use of a virtual machine running Linux running in the HyperKit Hypervisor. This virtual machine is lightweight and effectively hidden from the user.
Likewise Docker Desktop for Windows makes use of a virtual machine running in the Hyper-V Hypervisor. It can also run Windows containers.
To run Windows containers you need to have a Windows machine running Docker. The Windows machine can be virtual machine running on a Mac or Linux machine.
I know I am late to the party but as of 2021, this is the easiest setup to get a windows container running on macOS:
https://github.com/StefanScherer/windows-docker-machine
Install vagrant and virtual box
Clone the repository above and change directory into it
vagrant up --provider virtualbox 2019-box
docker context use 2019-box
I followed this setup and I could use the following windows image
mcr.microsoft.com/windows/servercore:ltsc2019
Please note that the windows version of your host must match the container image. This is mentioned here: https://hub.docker.com/_/microsoft-windows
Windows requires the host OS version to match the container OS
version. If you want to run a container based on a newer Windows
build, make sure you have an equivalent host build.

How can I run a docker windows container on osx?

I'm running docker for mac and want to start up a windows container. From what I see this should work via a virtual machine. But I'm unclear where to find out how to get it to work? Or does it only work for linux containers? Thanks in advance!
docker build nanoserver/
Sending build context to Docker daemon 2.56kB
Step 1/6 : FROM microsoft/nanoserver:10.0.14393.1480
10.0.14393.1480: Pulling from microsoft/nanoserver
bce2fbc256ea: Pulling fs layer
baa0507b781f: Pulling fs layer
image operating system "windows" cannot be used on this platform
I know I am late to the party but as of 2021, this is the easiest setup to get a windows container running on macOS:
https://github.com/StefanScherer/windows-docker-machine
Install vagrant and virtual box
Clone the repository above and change directory into it
vagrant up --provider virtualbox 2019-box
docker context use 2019-box
I followed this setup and I could use the following windows image
mcr.microsoft.com/windows/servercore:ltsc2019
Please note that the windows version of your host must match the container image. This is mentioned here: https://hub.docker.com/_/microsoft-windows
Windows requires the host OS version to match the container OS
version. If you want to run a container based on a newer Windows
build, make sure you have an equivalent host build.
See this link:
https://forums.docker.com/t/how-do-i-start-a-windows-docker-container-on-my-mac-os-x/12953/2
Text if you can't follow the link:
On OS X, get VirtualBox.
Get Windows Server 2016 Tech Preview 5 ISO167 (free download from Microsoft)
Create WS 2016 TP5 VM in virtualbox
Run this206 in the new VM
Now you can run Windows Containers in the VM. To make the setup a little easier to use, see this: https://forums.docker.com/t/windows-server-2016-tp5-docker-server-remote-management/10315/5317
You could also install Bootcamp on your machine which allows you to dual boot your computer between OS X and Windows 10. You could then use the full power of your hardware dedicated to Windows and docker instead of virtualization.
Additionally, you can make the use of VMWare Fusion for Mac OS or Parallels, which allow you to ALSO access the dual boot windows partition from within the Mac OS for maximum flexibility. During installation make sure you do not create a Virtual Machine drive, but instead access the bootcamp partition directly.

What is the overhead of using docker on windows, since I still have to download virtualbox

I am trying to build several components in docker who have indirect or direct dependencies after which I have to perform testing.I am using windows as my OS and have installed docker in that. What is the overhead of using docker on windows, since I still have to download virtualbox.

Possible to build and run Docker images in Linux VM on Parallels on OS X?

I'm just getting started with Docker and use a MacBook Pro for development work. I see the Docker instructions recommend using Virtual Box and Boot2Docker in this environment. Anyone know if it would also work in a Linux VM in Parallels?
You can totally run Docker in another kind of Linux VM.
If you already have some kind of Linux VM running, just check Docker installation instructions for the distro installed in the Linux VM.
If you don't have a Linux VM, or if you don't want to touch your existing Linux VM, you can also download boot2docker, and when creating the new VM, just attach the boot2docker image as a virtual CD-ROM image or a virtual hard disk image (yes, it actually supports both).

Resources