søndag den 18. februar 2018

Running Docker on Homebrew

Docker has been growing in popularity among developers and sysadmins for the last few years, but it wasn’t until recently I decided to look into it for some of the projects I run in my sparetime, and try it out for myself.

What is Docker?

Docker is an open-source engine that automates the deployment of any application as a lightweight, portable, self-sufficient container that will run virtually anywhere.
Docker ships applications using containers, containing any requirements for running the application, ensuring that the application runs in the same manner in production as in development. The use of containers also makes the systems isolated, enabling developers to run applications and their requirements inside a virtual machine, instead of having to install requirements on the workstation.
This means that getting a development environment up and running Rails, Wordpress etc., is now a matter of getting the right image from the Docker repository, and Docker will set up all requirements (application, database, webserver etc.)
There is one catch though, on Mac: It uses technology that doesn’t work natively on Mac. However in recent versions, it’s become pretty easy to handle, as Docker has a lightweight Linux VM, which allows it to run on Mac.

Getting started

We’ll start off by installing Virtualbox, as it’s needed to run the Linux VM. I usually use Homebrew Cask for installing apps, so this is based on you having Homebrew and Homebrew Cask installed on your Mac. Cask is an addon for Homebrew for installing Mac binary packages via the command line. This allows you to install applications like Chrome, OmniFocus, Alfred etc. through command line, rather than having to locate them and download the apps. manually.
Anyway - as mentioned previously, running Docker on a Mac requires VirtualBox, so install that:
brew cask install virtualbox
Then install Docker and the addon boot2docker:
brew install docker
brew install boot2docker
boot2docker installs the VM that Docker needs, in order to run on the Mac. The following will download and install the VM, and setup the daemon that Docker needs to run:
boot2docker download
boot2docker init
boot2docker up
Note: If boot2docker tells you to set DOCKER_HOST manually in order to connect to Docker, you may need to run the command given from the command line (It should look like this export DOCKER_HOST=tcp://localhost:4243).
The docker command line tool should now be ready to talk to the daemon, and you should be able to start up a Docker instance.
I had some issues with port forwarding, when I launched my first Docker instance on my laptop - as I needed to explicitly forward the ports needed for access through VirtualBox. This is a known issue on Mac, which a lot of developers experience. 

3 kommentarer:

  1. hey nice source for us, thanks for sharing this details and i read the whole information and it is really helpful for me.

    Hire CMS Web Developers

    SvarSlet
  2. Without spending much amount you can reach dedicated SEO Services Dublin audience and grow your business. There are lot of new features coming up with digital marketing that is surely making it so popular.

    SvarSlet
  3. It is always good to invest on the best designing services. In today’s time there are many popular, SEO services Danmark as well as genuine web designing services coming up. We are proud that we have in store for you the best and most exciting new ranges of web designing solutions. With our professionals you can get fast as well as effective solution in quick time.

    SvarSlet

Hvad er et CMS

Et CMS (Content Management System) er et program, der bruges til at styre indholdet på en hjemmeside - tekst, billeder, menu, kontaktformu...