迹忆客 EN >

当前位置:主页 > 学无止境 > 操作系统 > Docker >

使用 Homebrew 安装 Docker

作者:迹忆客 最近更新:2023/03/22 浏览次数:

毫无疑问,Docker 容器彻底改变了我们开发和部署应用程序的方式。它们为开发人员提供了在隔离环境中打包应用程序和依赖项的能力。

最近,我们已经看到 Docker 作为终极容器化平台被广泛采用。正因为如此,在所有平台上设置 Docker 都得到了极大的简化,包括 macOS 和 Windows。

在 macOS 中使用 Homebrew 安装 Docker

Docker 支持最新版本的 macOS,包括 macOS Big Sur、macOS Monterey 和 macOS Catalina。Docker 提供了一个本地应用程序,我们可以将其安装在 Applications 目录下并在 /usr/local/bin 中创建符号链接。

使用 Homebrew 安装 Docker。它是一个开源软件包管理系统,我们可以用来在 macOS 上安装应用程序。

Homebrew 将软件包安装到它们的目录,然后将它们的文件符号链接到 /usr/local。可以通过在终端中运行以下命令来安装 Homebrew。

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

现在已经安装 Homebrew 来安装 Docker,执行以下命令。

brew cask install docker

此命令将下载 docker 包,运行 Docker 安装程序,并打开 GUI 以设置配置。使用以下命令验证安装是否成功。

docker --version

如前所述,Homebrew 将软件包安装到它们的目录,然后将它们的文件符号链接到 /usr/local(在 macOS Intel 上)。但是,在 Brew 安装 Docker 之后,在 /usr/local/bin 中可能无法使用 docker 命令(符号链接)。

要解决此问题,请按照以下步骤操作。

  • +Space打开 Spotlight Search,然后输入 Docker 启动 Docker。
  • Docker 需要特权访问对话框中,单击确定
  • 输入密码并点击 OK
  • 一旦我们启动了 Docker,一个类似鲸鱼的图标现在应该在状态菜单中可见。这意味着所有指向 Docker 位置的符号文件都已在 /usr/local/bin 中正确设置。
  • 你可以通过在终端中执行以下命令来确认这一点。

代码:

$ ls -l /usr/local/bin/docker*

现在单击 Docker 图标并等待 Docker 启动。

Docker 图标

最后,我们将运行以下命令来测试你的 Docker 安装是否正确设置。

$ docker run hello-world

输出:

Docker hello world

我们已经从 Docker 注册表中提取了 hello-world 映像,并使用此命令成功创建了一个 Docker 容器。这表示 Docker 现在已在你的系统中正确设置。

转载请发邮件至 1244347461@qq.com 进行申请,经作者同意之后,转载请以链接形式注明出处

本文地址:

相关文章

Solution to incorrect access log time when deploying Nginx in Docker

发布时间:2025/03/26 浏览次数:165 分类:Docker

In the process of operating the website, I never took the logs too seriously. Although logging was turned on, I never analyzed the logs carefully. Today, when I looked at the logs on a whim, I found that the recorded time was 8 hours less t

Docker deploys nginx php application

发布时间:2025/03/26 浏览次数:131 分类:Docker

I'm learning docker recently. I'm learning by building an nginx+php development environment example. Here I record the build process. First, give a docker-compose.yml deployment configuration file version: '3' services: nginx: container_nam

How to use Docker to image a Node.js web application

发布时间:2025/03/26 浏览次数:107 分类:Docker

Docker is a containerization platform that simplifies the packaging and execution of applications. Containers run as independent processes with their own file systems, but share the kernel of their host machine. Docker has attracted much at

Start a Bash terminal in a new Docker container

发布时间:2025/03/26 浏览次数:97 分类:Docker

Docker containers are a standard unit for packaging all the dependencies of an application, allowing us to easily run them in any environment. Containers have become very popular recently, and most developers now rely heavily on containers

Passing environment variables to containers in Docker

发布时间:2025/03/26 浏览次数:124 分类:Docker

This article will introduce how to pass environment variables to containers in Docker. Passing environment variables to containers in Docker using the -e and tags -env We will first see how to create environment variables and pass them to t

Install Docker using Homebrew

发布时间:2025/03/26 浏览次数:202 分类:Docker

There is no doubt that Docker containers have revolutionized the way we develop and deploy applications. They provide developers with the ability to package applications and dependencies in an isolated environment. Recently, we've seen wide

Enforce clean build of images in Docker

发布时间:2025/03/26 浏览次数:87 分类:Docker

This article discusses and demonstrates how to enforce clean builds of images in Docker. Building images in Docker We will use a simple Flask application to demonstrate this concept. my-app Create a app.py simple application named in the ho

Running a Docker instance from a Dockerfile

发布时间:2025/03/26 浏览次数:140 分类:Docker

Docker containers have undoubtedly become the standard unit for managing software and dependencies in different environments. When using real applications, you must create a docker file before building the container image of the application

扫一扫阅读全部技术教程

社交账号
  • https://www.github.com/onmpw
  • qq:1244347461

最新推荐

教程更新

热门标签

扫码一下
查看教程更方便