Docker from mac os

Docker на macOS

Немного о консольных составляющих

docker — утилита, общающаяся через сокет с хостом Docker ( docker daemon ). Является клиентом.

docker-machine — средство для управления машинами с Docker, а так же их создания. Расширярется так называемыми драйверами.

docker-compose — утилита для определения и выполнения кросс-контейнерных приложений. Позволяет объединить и настроить связку отдельных приложений в контейнерах, например, для веб-сервера: nginx, MySQL, PHP.

Использование MacOS машины как хоста

Самый очевидный способ использования Docker на Mac, учитывая, что Docker может создавать контейнеры только на ядре Linux, это использование виртуальной машины. Уже самые первые Mac на платформе Intel позволяли использовать паравиртуализацию и аппаратное ускорение для запуска виртуальных машин, но родного гипервизора не было: различные производители ПО, вроде VMware и Parralells заняли нишу гипервизоров на MacOS. Конечно же, было еще и бесплатное решение от Oracle (Virtual Box), но оно не такое удобное. В любом случае эти гипервизоры были сделаны в виде расширения ядра и порой были не очень стабильны. Начиная с Yosemite Apple добавили Hypervisor.framework, представляющий из себя API для создания HVM (аппаратных виртуальных машин). Сложно назвать это средство полноценным гипервизором, но первое достаточно массовое решение на нем — xhyve и Veertu. xhyve — гипервизор, портированный с FreeBSD и позволяет запускать Linux-машины.

До появления Hypervisor.framework и проекта xhyve предлагалось запускать Docker в виртуальной машине, используя гипервизор Virtual Box или любой другой (при помощи утилиты docker-machine у которой есть свои «драйверы», позволяющие автоматизировать создание, запуск и работу с виртуальными машинами) из предложенных. Это legacy-решение, но оно до сих пор поддерживается.

Современное же решение – это запуск виртуальной машины с использованием встроенного в MacOS процесса виртуализации. Docker назвали его HyperKit и его кодовая база практически полностью основана на проекте xhyve.

Старый способ (Docker Toolbox), как и драйверы для многих гипервизоров, разворачивают в стороннем гипервизоре образ ОС Boot2Docker.

Современный способ (Docker for Mac)

Данный способ поддерживает только Yosemite 10.10.3 и старше, но рекомендуется El Capitan и выше. Используется HyperKit, встроенная в MacOS виртуализация.

Установка проста и описана на странице Docker for Mac. Необходимо скачать DMG-контейнер, перетащить его содержимое и запустить Docker. Будут установлены консольные утилиты (docker, docker-machine, docker-compose), а также графическая оболочка для управления виртуальной машиной, в которой запущен Docker и бета-версия официальной графической утилиты для управления контейнерами Kitematic. Сразу же после этого можно использовать Docker в полную силу.

Старый способ (Docker Toolbox)

Установка так же простая и описана на странице Docker Toolbox. Установщик сам установит все необходимое, в том числе и гипервизор Oracle VirtualBox. Управлять можно с приложения Kitematic и терминала. Специально сделан шорткат, который можно найти в Launchpad и который позволит подключиться к виртуальной машине. Его же необходимо будет запустить в первый раз, так как он сам сделает виртуальную машину и настроит ее. Далее можно подключаться просто с терминала, выполнив вначале eval $(docker-machine env dev) , после чего можно общаться с docker посредством команды docker .

Рекомендуется настроить виртуальную машину Virtual Box так, чтобы она имела статический IP адрес, но была за NAT. В таком случае можно будет запускать контейнер через docker-machine или VBoxManage , либо с графического интерфейса, после чего работать с ней с обычного терминала.

Другой гипервизор

Для использования другого гипервизора необходимо установить комплект консольных утилит (docker, docker-mahine, docker-compose[^*]). Сделать это можно, установив Docker любым из способов, описанных выше, либо установив консольные утилиты через Homebrew. Кроме того, если уже установлен Virtual Box и Homebrew, то установив через него утилиты можно сделать виртуальные машины для Docker и управлять самим Docker.

[^*]: Необязателен для использования, зависит от поставленной задачи.

Чтобы создать виртуальную машину через docker-machine необходимо изучить документацию к необходимому драйверу. Для тех, что присутствуют по умолчанию, можно посмотреть в официальной документации Docker. Например, для создания виртуальной машины в VMware Fusion необходимо выполнить

Читайте также:  Linux bios время utc

После чего для для управления через docker необходимо выполнить

Чтобы точно знать, что мы управляем нужной машиной всегда можно набрать

Использование облачных сервисов и управление через Docker API

Другая машина (VPS, VDS, любой «соседний» ПК на Linux или ВМ)

Чтобы управлять Docker на любой другой машине необходимо воспользоваться драйвером Generic. Он позволит добавить через SSH с ключом или паролем любую машину в реестр docker-toolbox для удобства дальнейшего подключения через утилиту docker .

Почитать по управлению с по мощью драйвера можно в отдельной статье.

IaaS Azure, AWS, OpenStack и прочие

Используя необходимый драйвер в docker-machine можно создать виртуальную машину с Docker на практически любом популярном IaaS сервисе.

Для примера разберем MS Azure в отдельной статье.

Дополнительные драйверы для docker-machine

Если хочется использовать Docker с xhyve или же Parallels, Vultr, то можно поставить драйверы их Homebrew.

Автодополнение Docker для шелла

Чтобы было наиболее удобно управлять Docker имеет смысл установить автодополнение для шела. К сожалению, в версии для Mac оно не поставляется ни в одном варианте.

Homebrew

Если еще не установлен менеджер пакетов brew, то стоит его установить.

/usr/bin/ruby -e «$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)»

Лучше использовать шел ZSH. Он легко расширяется модулями и для него больше хороших модулей автодополнения. <==Почитать про устновку можно в отдельной статье==>.

Установить автодополнение для docker, docker-machine, docker-compose не составит труда.

brew install docker-completion docker-machine-completion docker-compose-completion

После установки чтобы автодополнение работало проще всего открыть новую вкладку терминала и проверить работоспособность.

Для установки автодополнения для шела bash необходимо выполнить после установки с Homebrew.

Только установка docker (CLI), docker-machine, docker-compose

Используя Homebrew можно установить указанные выше утилиты для управления docker на любой виртуальной (иди другой) машине без лишних утилит. Можно добавить машину в docker-machine и легко получить к ней доступ через команду eval $(docker-machine env machinename) , после чего управлять ей через docker .

Copyright © 2017 Александр Пинегин aka Bloody Foxy

Источник

Install Docker Desktop on Mac

Estimated reading time: 7 minutes

Welcome to Docker Desktop for Mac. This page contains information about Docker Desktop for Mac system requirements, download URLs, instructions to install and update Docker Desktop for Mac.

Download Docker Desktop for Mac

System requirements

Your Mac must meet the following requirements to install Docker Desktop successfully.

Mac with Intel chip

macOS must be version 10.14 or newer. That is, Mojave, Catalina, or Big Sur. We recommend upgrading to the latest version of macOS.

If you experience any issues after upgrading your macOS to version 10.15, you must install the latest version of Docker Desktop to be compatible with this version of macOS.

Docker supports Docker Desktop on the most recent versions of macOS. That is, the current release of macOS and the previous two releases. As new major versions of macOS are made generally available, Docker stops supporting the oldest version and supports the newest version of macOS (in addition to the previous two releases). Docker Desktop currently supports macOS Mojave, macOS Catalina, and macOS Big Sur.

At least 4 GB of RAM.

VirtualBox prior to version 4.3.30 must not be installed as it is not compatible with Docker Desktop.

Mac with Apple silicon

You must install Rosetta 2 as some binaries are still Darwin/AMD64. To install Rosetta 2 manually from the command line, run the following command:

Install and run Docker Desktop on Mac

Double-click Docker.dmg to open the installer, then drag the Docker icon to the Applications folder.

Double-click Docker.app in the Applications folder to start Docker. In the example below, the Applications folder is in “grid” view mode.

The Docker menu () displays the Docker Subscription Service Agreement window. It includes a change to the terms of use for Docker Desktop.

Here’s a summary of the key changes:

  • Our Docker Subscription Service Agreement includes a change to the terms of use for Docker Desktop
  • It remains free for small businesses (fewer than 250 employees AND less than $10 million in revenue), personal use, education, and non-commercial open source projects.
  • It requires a paid subscription for professional use in larger enterprises.
  • The effective date of these terms is August 31, 2021. There is a grace period until January 31, 2022 for those that will require a paid subscription to use Docker Desktop.
  • The existing Docker Free subscription has been renamed Docker Personal and we have introduced a Docker Business subscription .
  • The Docker Pro, Team, and Business subscriptions include commercial use of Docker Desktop.
Читайте также:  Hklm software microsoft windows currentversion policies system enablelua

Click the checkbox to indicate that you accept the updated terms and then click Accept to continue. Docker Desktop starts after you accept the terms.

If you do not agree to the terms, the Docker Desktop application will close and you can no longer run Docker Desktop on your machine. You can choose to accept the terms at a later date by opening Docker Desktop.

For more information, see Docker Desktop License Agreement. We recommend that you also read the Blog and FAQs to learn how companies using Docker Desktop may be affected.

Quick start guide

If you’ve just installed the app, Docker Desktop launches the Quick Start Guide. The tutorial includes a simple exercise to build an example Docker image, run it is a container, push and save the image to Docker Hub.

Congratulations! You are now successfully running Docker Desktop. Click the Docker menu () to see Preferences and other options. To run the Quick Start Guide on demand, select the Docker menu and then choose Quick Start Guide.

Updates

When an update is available, Docker Desktop displays an icon to indicate the availability of a newer version.

Starting with Docker Desktop 4.1.0, the Software Updates section in the General tab also notifies you of any updates available to Docker Desktop. You can choose to download the update right away, or click the Release Notes option to learn what’s included in the updated version. If you are on a Docker Team or a Business subscription, you can turn off the check for updates by clearing the Automatically Check for Updates checkbox in the General settings. This will also disable the notification badge that appears on the Docker Dashboard.

To encourage developers to stay up to date, Docker Desktop displays a reminder two weeks after an update becomes available. You can dismiss this daily reminder by clicking Snooze. You can skip an update when a reminder appears by clicking the Skip this update option.

Docker Subscription Service Agreement

Beginning on August 31, 2021, you must agree to the Docker Subscription Service Agreement to continue using Docker Desktop. Read the Blog and the Docker subscription FAQs to learn more about the changes.

Click Download update When you are ready to download the update. This downloads the update in the background. After downloading the update, click Update and restart from the Docker menu. This installs the latest update and restarts Docker Desktop for the changes to take effect.

When Docker Desktop starts, it displays the Docker Subscription Service Agreement window. Read the information presented on the screen to understand how the changes impact you. Click the checkbox to indicate that you accept the updated terms and then click Accept to continue.

If you do not agree to the terms, the Docker Desktop application will close and you can no longer run Docker Desktop on your machine. You can choose to accept the terms at a later date by opening Docker Desktop.

Docker Desktop starts after you accept the terms.

Uninstall Docker Desktop

To uninstall Docker Desktop from your Mac:

  1. From the Docker menu, select Troubleshoot and then select Uninstall.
  2. Click Uninstall to confirm your selection.

Uninstalling Docker Desktop destroys Docker containers, images, volumes, and other Docker related data local to the machine, and removes the files generated by the application. Refer to the back up and restore data section to learn how to preserve important data before uninstalling.

Источник

Install Docker on macOS

Docker for Mac offers a Mac native application that installs in /Applications . It creates symlinks (symbolic links) in /usr/local/bin for docker and docker-compose to the Mac versions of the commands in the application bundle.

The Docker for Mac bundle installs:

  1. Docker Engine
  2. Docker CLI Client
  3. Docker Compose
  4. Docker Machine

Are you already running Docker Toolbox and/or Docker Machine?

If so, you need to do a little more work. First, check whether Docker Toolbox environment variables are set:

If you don’t get output, you can go ahead and use Docker for Mac. However, if you do get output (like in the example), you need to unset the Docker variables so the client can talk to the Docker for Mac Engine. Run:

If you use Bash, you can use unset $ to unset all of the Docker environment variables (this does not work in other shells, like zsh or csh ).

Читайте также:  Send to windows add

When you run env | grep DOCKER now, you should see no output.

Running Docker Toolbox and Docker for Mac on the same host

You can run both Docker Toolbox and Docker for Mac on the same system, but not at the same time.

When you use Docker for Mac, you need to unset all of your environment variables, using one of the methods above. When you want to use a VirtualBox VM you have set up with docker-machine , simply run eval $(docker-machine env default) (assuming you want to target the machine “default”).

Docker Machine

Docker for Mac does not affect previous machines created via Docker Machine, The installation gives you the option to copy containers and images from your local default machine if you have one.

Requirements

You must have a Mac:

  1. 2010 or newer, with Intel’s hardware Memory Management Unit (MMU).
  2. OS X 10.10.3 Yosemite or newer (or macOS).
  3. At least 4 GB of RAM.
  4. You must not have a VirtualBox installation earlier than version 4.3.30 on your system. If you do, you’ll need to uninstall it.

Before You Install

Take a few minutes to understand some key concepts before you install Docker.

On an “out-of-the-box” Linux installation, the Docker client, daemon, and all containers run directly on localhost, meaning you can access ports on a Docker container using localhost addressing; something like localhost:8080 or 0.0.0.0:8376 .

On macOS, Docker’s daemon runs inside a Linux VM. The macOS Docker client talks to the Docker host VM, and your containers run on the host. You cannot use localhost in this setting; instead, the container’s ports map to the VM’s ports. If your VM has the IP address 10.0.0.5, access the ports like 10.0.0.5:8000 or 10.0.0.5:8376 .

Installation

  1. Download Docker.
  2. Double-click the DMG file, and drag-and-drop Docker into your Applications folder.
  3. You need to authorize the installation with your system password.
  4. Double-click Docker.app to start Docker.
  5. The whale in your status bar indicates Docker is running and accessible.
  6. Docker presents some information on completing common tasks and links to the documentation.
  7. You can access settings and other options from the whale in the status bar. a. Select About Docker to make sure you have the latest version.

Verification

Check versions of Docker Engine, Compose, and Machine.

Run a Dockerized web server to make sure everything works:

If you do not have the image locally, Docker pulls it from Docker Hub (more on this later). Visit http://localhost to bring up your new homepage; you should see:

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com.

Thank you for using nginx.

Common Pitfalls

Operating System

Unfortunately, if you do not run “Mountain Lion” or later, you cannot run Docker for Mac. You can upgrade your OS to the most recent viable version, provided your system supports it.

Shell Scripts

If you use a shell script to set the Docker environment variables every time you open a command window (Terminal), you need to unset the variables every time you use Docker for Mac (alternately, you can write a shell script to follow behind and unset the variables).

Multiple Docker Versions

Docker for Mac replaces docker and docker-compose with its own versions; if you already have Docker Toolbox on your Mac, Docker for Mac still replaces the binaries. You want the Docker client and Engine to match versions; mismatches can cause problems where the client and host cannot communicate. If you already have Docker Toolbox, and then you install Docker for Mac, you may get a newer version of the Docker client. Running docker version in a command shell displays the version of the client and server you have on your system.

This may also happen if you use Docker Universal Control Plane (UCP).

If you want to support both Docker Toolbox and Docker for Mac, check out the Docker Version Manager (DVM).

Next: Install Docker on Windows 10
Requirements and things to know before installing Docker for Win 10.

By Runnable: The service that speeds up development by providing full-stack environments for every code branch.

Источник

Оцените статью