Docker is a tool that makes containers: local environments in which you can run certain versions of software (I haven’t explained this very well). This means that you can, for example, set up a local webserver with the specific versions of PHP, Apache and MySQL that your app or site depends on. I went to a Bristol PHP Training session on Docker a couple of weeks ago, and Nigel took us through all the basic possibilities.
Installing Docker on Mac is pretty straightforward. It has a Graphical installer.dmg file. The installation provides Docker Engine, Docker CLI client, Docker Compose, Docker Machine, and Kitematic. Pre-requisites for installing Docker on Mac. Docker requires OS X El Capitan 10.11 or newer macOS release running on a 2010 or newer Mac. OS X (from El Capitan 10.11 on) or OS X (before El Capitan 10.11). Once Docker is installed, open up the docker terminal and test it works with the command: docker run hello-world Note: Linux users might need to use sudo to run docker commands or follow post-installation steps. Install Docker on El Capitan. GitHub Gist: instantly share code, notes, and snippets.
One problem is that I am stuck on OS X 10.11 El Capitan, with which Docker for Mac isn’t compatible, and I couldn’t use the Docker Toolbox installer. Instead I had to follow this article to install Docker on Mac OS X 10.11.
I used VirtualBox to create a new Docker virtual machine, devbox
.
Now, when I need to use Docker, I run:
This enters the virtual machine. The key difference with using Docker as a virtual machine is that, where you would use localhost
to access your sites, you need to use the virtual machine’s IP address. This can be found using:
So far I’ve managed to set up the Wagtail Bakery demo using Docker, and a PHP 5.6 server to run an outdated site that I need to refactor. These are all things that I wouldn’t have had a clue how to do a few months ago, so thanks Nigel, and thanks Docker!
Question or issue on macOS:
Docker Toolbox El Capitan
I am using Docker for Mac and wish to create Docker image running a Mac El Capitan with my development env.
I am not finding any resources on this. All I see is Linux installations.
On Linux I saw things as simple as:
But what would be the FROM value for OS X to install and run other software?
How to solve this problem?
Solution no. 1:
If you are trying to run Mac OS as the base system in a Docker container, unfortunately there is no way to do it.
Docker container need to use the host machine’s Linux Kernel, since Mac OS family is Unix-based operating system, currently Docker cannot simulate a Mac OS in Docker container. Here is a link to explain how container works.
Solution no. 2:
This would be nice, particularly for CI servers:
Docker El Capitan Update
- You can run OSX on QEMU (akin to VirtualBox, emulates the
kernel). - You canrun QEMU from a Docker container. I have
done this for ARM dev and it works well. - So yes, you can run OSX
from Docker, but you have to emulate, use a virtual
machine in the container.
Solution no. 3:
If hardware virtualization (KVM) is available on your host, you can now use Docker-OSX to run/emulate macOS on QEMU/KVM via OSX-KVM.