Tailwind Logo

Setting up a Docker environment (macOS version)

Docker

Published: 2023-10-12

Before that, we need to prepare tools for integrating with Search. This time, we'll set up the Docker environment. Today, I'll cover the macOS setup, and tomorrow, I'll share notes on how I handle the Windows environment.

Prerequisite

The machine we are working on this time is as follows

  • MacBook Pro 14 ( 2021 )
  • Apple M1 Max
  • Memory 32GB
  • macOS Sonoma 14.0

This machine is an M1, which means it is an ARM version of the MacBook. Therefore, it is not possible to use Windows containers, but it is possible to use Linux containers. In this article, we will introduce the procedure.

Install

As for installation, this time, simply install Docker Desktop.

Basically, this allows you to use Docker.

How to use Linux containers

Even if you install the Docker Desktop mentioned above, it will download the ARM version of the container and install tools for macOS. You can use the amd64 version of the Linux container by specifying the platform.

The platform is specified in the docker-compose.yml file as follows. First, let's create an image without specifying the platform. The container image is created as follows.

dockermacos01.png

Then, specify linux/amd64 for platform.

YAML
services:
  playwright:
    image: ${COMPOSE_PROJECT_NAME}-playwright:${PROJECT_VERSION}
    platform: linux/amd64
    build:      context: ./src/playwright

The actual build of the image is as follows.

dockermacos02.png

Now you can build a Linux container. However, a few more steps are required. However, a few more steps are required, since Linux containers are not compatible with ARM-based macOS, such as M1. This can be resolved by using the Docker Desktop settings: open the Features in Develpoment screen and you will see the following checkboxes

dockermacos03.png

Rosetta should be checked in Apple Silicon to work. If this is not checked, please make sure that Use Virtualization framework in General is checked.

Summary

When using Docker on a MacBook with a different CPU architecture, there is a container for ARM, which is not so inconvenient for use on hand, but the above configuration allows you to use images for deployment in the cloud on hand.

Tags