M1 Mac에서 Docker 환경을 만든 기록

16110 단어 초보자도커M1
M1 Mac용 Docker가 새로워졌으므로 설치해 보았습니다.
지난달 도전했을 때는 아무래도 움직이지 않았습니다. 이번이야말로!

환경



MacBook Air (M1, 2020)
OS:Big Sur Ver11.2

Docker 설치



이 기사에서 Apple M1 칩 대응의 Docker Desktop, 동고의 Kubernetes도 실행 가능 - Publickey

Docker 개발 블로그에 가서 Apple Silicon Tech Preview | Docker Documentation Docker Desktop RC 2를 다운로드했습니다.

Docker Desktop RC 2🔗
2021-03-26

갓 만든 호야 호야!

Docker.dmg를 두 번 클릭하여 실행합니다. 응용 프로그램에 복사하여 시작.

오류가되었습니다!




[   14.057444] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
[   14.057511] Mem abort info:
[   14.057517]   ESR = 0x86000005
[   14.057568]   Exception class = IABT (current EL), IL = 32 bits
[   14.057608]   SET = 0, FnV = 0
[   14.057647]   EA = 0, S1PTW = 0
[   14.057674] user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000ff152e3f
[   14.057705] [0000000000000000] pgd=00000000da451003, pud=0000000000000000
[   14.059417] Internal error: Oops: 86000005 [#1] PREEMPT SMP
[   14.059451] Modules linked in: xfrm_user xfrm_algo vmw_vsock_virtio_transport vmw_vsock_virtio_transport_common vsock
[   14.059493] Process 010-onboot (pid: 275, stack limit = 0x0000000028742d26)
[   14.059555] CPU: 2 PID: 275 Comm: 010-onboot Tainted: G                T 4.19.121-linuxkit #1
[   14.059620] pstate: 20401085 (nzCv daIf +PAN -UAO)
[   14.059624] pc :           (null)
[   14.063044] lr : __wake_up_common+0xc0/0x174
[   14.063089] sp : ffff0000098d3bc0
[   14.063108] x29: ffff0000098d3bc0 x28: 0000000000000000 
[   14.063120] x27: 0000000000000000 x26: ffff800098244d88 
[   14.063140] x25: 0000000000000000 x24: 0000000000000000 
[   14.063156] x23: 0000000000000001 x22: 0000000000000000 
[   14.063182] x21: ffffffffffffffe8 x20: ffff000009aebb80 
[   14.063196] x19: ffff0000098d3c70 x18: 0000000000000000 
[   14.063211] x17: 0000000000000000 x16: 0000000000000000 
[   14.063238] x15: 0000000000000000 x14: 0000000000000000 
[   14.063257] x13: 0000000000000000 x12: 0000000000000000 
[   14.063286] x11: 0000000000000000 x10: 0000000000000000 
[   14.063304] x9 : 0000000000000000 x8 : ffff0000098d3df8 
[   14.063367] x7 : 0000000000000000 x6 : 0000000000000003 
[   14.063383] x5 : ffff0000098d3c70 x4 : 0000000000000000 
[   14.063408] x3 : 0000000000000000 x2 : 0000000000000000 
[   14.063443] x1 : 0000000000000001 x0 : ffff000009aebb80 
[   14.063459] Call trace:
[   14.063466]            (null)
[   14.063478]  __wake_up_common_lock+0x84/0xc8
[   14.063495]  __wake_up+0x40/0x50
[   14.063522]  sock_def_wakeup+0x48/0x58
[   14.064996]  unix_release_sock+0x140/0x228
[   14.065042]  unix_release+0x28/0x3c
[   14.065056]  __sock_release+0x48/0xb0
[   14.065071]  sock_close+0x24/0x34
[   14.065117]  __fput+0xec/0x1e0
[   14.065173]  ____fput+0x20/0x2c
[   14.065197]  task_work_run+0x8c/0xb0
[   14.065210]  do_notify_resume+0xf4/0x11c
[   14.065241]  work_pending+0x8/0x10
[   14.065260] Code: bad PC value
[   14.066906] ---[ end trace 5717b31f77e4ee04 ]---

pgtable은 무엇일까? ? ?

우선 Restert 버튼을 누르십시오.



위의 바에 배의 마크가 나왔다···기동했다···? ? ?

docker pull continuumio/anaconda3:2019.03 실행



docker의 이미지를 당깁니다.
(base) [22:52:17 9 JPX]$ docker pull continuumio/anaconda3:2019.03
2019.03: Pulling from continuumio/anaconda3
c5e155d5a1d1: Pull complete 
86534c0d13b7: Pull complete 
5764e90b1fae: Pull complete 
ba67f7304613: Pull complete 
Digest: sha256:2342379103968c3a45c8f49517ab2dff7638dd6a3842cb9cff9792acd92fa928
Status: Downloaded newer image for continuumio/anaconda3:2019.03
docker.io/continuumio/anaconda3:2019.03
(base) [23:00:00 10 JPX]$ 

Docker 이미지 만들기



이 기사를 참고로했습니다.
【이미지로 설명】Docker로 Anaconda 환경을 만들고 컨테이너 안에서 VSCode 사용하기 - Qiita

Dockerfile 만들기



이미지의 위치로 이동하여
여기를 Dockerfile라는 파일 이름으로 저장합니다.
# ベースイメージ名:タグ名
FROM continuumio/anaconda3:2019.03

# pipをアップグレードし必要なパッケージをインストール
RUN pip install --upgrade pip && \
    pip install autopep8 && \
    pip install Keras && \
    pip install tensorflow 

# コンテナ側のルート直下にworkdir/(任意)という名前の作業ディレクトリを作り移動する
WORKDIR /workdir

# コンテナ側のリッスンポート番号
# 明示しているだけで、なくても動く
EXPOSE 8888

# ENTRYPOINT命令はコンテナ起動時に実行するコマンドを指定(基本docker runの時に上書きしないもの)
# "jupyter-lab" => jupyter-lab立ち上げコマンド
# "--ip=0.0.0.0" => ip制限なし
# "--port=8888" => EXPOSE命令で書いたポート番号と合わせる
# ”--no-browser” => ブラウザを立ち上げない。コンテナ側にはブラウザがないので 。
# "--allow-root" => rootユーザーの許可。セキュリティ的には良くないので、自分で使うときだけ。
# "--NotebookApp.token=''" => トークンなしで起動許可。これもセキュリティ的には良くない。
ENTRYPOINT ["jupyter-lab", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root", "--NotebookApp.token=''"]

# CMD命令はコンテナ起動時に実行するコマンドを指定(docker runの時に上書きする可能性のあるもの)
# "--notebook-dir=/workdir" => Jupyter Labのルートとなるディレクトリを指定
CMD ["--notebook-dir=/workdir"]

Docker 이미지 빌드



빌드하려는 위치 (이미지가있는 위치, Dockerfile과 같은 위치)로 이동하여,docker build -t jpx_image_file . 를 실행합니다.
(base) [23:03:45 13 JPX]$ docker build -t jpx_image_file .
[+] Building 100.8s (4/6)                                                       
 => [internal] load build definition from Dockerfile                       1.0s
 => => transferring dockerfile: 1.60kB                                     0.1s
 => [internal] load .dockerignore                                          1.1s
 => => transferring context: 2B                                            0.0s
 => [internal] load metadata for docker.io/continuumio/anaconda3:2019.03   3.8s
 => [1/3] FROM docker.io/continuumio/anaconda3:2019.03@sha256:23423791039  2.0s
 => => resolve docker.io/continuumio/anaconda3:2019.03@sha256:23423791039  0.1s
 => [2/3] RUN pip install --upgrade pip &&     pip install autopep8 &&    93.4s
 => => # ckages (from h5py->Keras) (1.12.0)                                    
 => => # Installing collected packages: Keras                                  
 => => # Successfully installed Keras-2.4.3                                    
 => => # Collecting tensorflow                                                 
 => => #   Downloading tensorflow-2.4.1-cp37-cp37m-manylinux2010_x86_64.whl (39
 => => # 4.3 MB)                                                               
(base) [23:06:04 14 JPX]$ 

docker-compose.yml 만들기



Docker 이미지를 시작하는 스크립트입니다.
이것도 같은 곳에 둡니다.

docker-compose.yml
version: '3' # docker-composeファイルの書式バージョン。最新の’3’を指定(2019/6/27現在)
services:
  dev: # 任意の名前(ディレクトリ名 + dev がコンテナ名となります)
    build:
      context: .
      dockerfile: Dockerfile
    image: jpx_image_file
    ports:
    - "8080:8888"
    volumes:
    - .:/workdir

컨테이너 시작


docker-compose up로 시작합니다.

(base) [23:14:27 17 JPX]$ docker-compose up
Docker Compose is now in the Docker CLI, try `docker compose up`

Building dev
[+] Building 188.4s (7/7) FINISHED                                              
 => [internal] load build definition from Dockerfile                       0.9s
 => => transferring dockerfile: 1.60kB                                     0.0s
 => [internal] load .dockerignore                                          0.7s
 => => transferring context: 2B                                            0.0s
 => [internal] load metadata for docker.io/continuumio/anaconda3:2019.03   2.7s
 => CACHED [1/3] FROM docker.io/continuumio/anaconda3:2019.03@sha256:2342  0.0s
 => [2/3] RUN pip install --upgrade pip &&     pip install autopep8 &&   174.8s
 => [3/3] WORKDIR /workdir                                                 0.8s
 => exporting to image                                                     8.5s 
 => => exporting layers                                                    8.3s 
 => => writing image sha256:c2bcf94244cead2c36628487e76b3bf6009ffd87de2ae  0.0s 
 => => naming to docker.io/library/jpx_image_file                          0.0s 
Successfully built c2bcf94244cead2c36628487e76b3bf6009ffd87de2ae78877f65ad6c13ba082
WARNING: Image for service dev was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating jpx_dev_1 ... 
Creating jpx_dev_1 ... error

ERROR: for jpx_dev_1  Cannot start service dev: driver failed programming external connectivity on endpoint jpx_dev_1 (2c8f5cb93aa49a9ab121ae2004db0b8b0a69ccbb44b63d2f8caffe76427fd14b): exec: "docker-proxy": executable file not found in $PATH

ERROR: for dev  Cannot start service dev: driver failed programming external connectivity on endpoint jpx_dev_1 (2c8f5cb93aa49a9ab121ae2004db0b8b0a69ccbb44b63d2f8caffe76427fd14b): exec: "docker-proxy": executable file not found in $PATH
ERROR: Encountered errors while bringing up the project.
(base) [23:17:48 18 JPX]$ 

무려, 여기까지 왔는데 기동하지 않는다!

exec: "docker-proxy": executable file not found in $PATH



에러로 넘어간다. docker-proxy 를 유효하게 하면 좋다.

linux - How to enable docker-proxy - Stack Overflow

첫째, docker-proxy가 있는지 여부.
(base) [23:31:16 8 ~]$ sudo find / -name \*docker-proxy 2> /dev/null
Password:
(base) [23:32:57 9 ~]$ 

아니.

냉정해지다



개발 블로그를 다시 한번 바라보면 Known issues 가 있었습니다.
Apple Silicon Tech Preview | Docker Documentation

The following issues are not expected to be resolved in the final GA build for Apple Silicon.

You must install Rosetta 2 as some binaries are still Darwin/AMD64. To install Rosetta 2 manually from the command line, use this command:
softwareupdate --install-rosettaWe expect to fix this in a future release.

softwareupdate --install-rosetta 실행


(base) [23:32:57 9 ~]$ softwareupdate --install-rosetta
I have read and agree to the terms of the software license agreement. A list of Apple SLAs may be found here: http://www.apple.com/legal/sla/
Type A and press return to agree: A
2021-03-27 23:45:08.664 softwareupdate[28887:1698436] Package Authoring Error: 071-00840: Package reference com.apple.pkg.RosettaUpdateAuto is missing installKBytes attribute
Install of Rosetta 2 finished successfully

docker-compose up 재실행



(base) [23:30:25 21 JPX]$ docker-compose up
Docker Compose is now in the Docker CLI, try `docker compose up`

Starting jpx_dev_1 ... 
Starting jpx_dev_1 ... error

ERROR: for jpx_dev_1  Cannot start service dev: driver failed programming external connectivity on endpoint jpx_dev_1 (1a56d12eecfe523f0778c71ccf53ef893980a4ecbce8f7f17a697853d6a55903): Bind for 0.0.0.0:8080 failed: port is already allocated

ERROR: for dev  Cannot start service dev: driver failed programming external connectivity on endpoint jpx_dev_1 (1a56d12eecfe523f0778c71ccf53ef893980a4ecbce8f7f17a697853d6a55903): Bind for 0.0.0.0:8080 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.

Bind for 0.0.0.0:8080 failed: port is already allocated

이미 할당되어 있습니다 ...? ? ?
Docker를 다시 시작하면 좋을까요? ? ?

Restart Docker



위의 바에서 배 표시를 클릭하여 Restart Docker를 실행했습니다.

docker-compose up 다시 실행


(base) [23:47:45 22 JPX]$ docker-compose up
Docker Compose is now in the Docker CLI, try `docker compose up`

Starting jpx_dev_1 ... done
Attaching to jpx_dev_1
dev_1  | [I 14:47:50.292 LabApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
dev_1  | [W 14:47:53.878 LabApp] All authentication is disabled.  Anyone who can connect to this server will be able to run code.
dev_1  | [I 14:47:53.945 LabApp] JupyterLab extension loaded from /opt/conda/lib/python3.7/site-packages/jupyterlab
dev_1  | [I 14:47:53.946 LabApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
dev_1  | [W 14:47:53.950 LabApp] JupyterLab server extension not enabled, manually loading...
dev_1  | [I 14:47:53.956 LabApp] JupyterLab extension loaded from /opt/conda/lib/python3.7/site-packages/jupyterlab
dev_1  | [I 14:47:53.957 LabApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
dev_1  | [I 14:47:53.958 LabApp] Serving notebooks from local directory: /workdir
dev_1  | [I 14:47:53.958 LabApp] The Jupyter Notebook is running at:
dev_1  | [I 14:47:53.958 LabApp] http://(643f31ccb6a3 or 127.0.0.1):8888/
dev_1  | [I 14:47:53.958 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
dev_1  | [I 14:48:26.258 LabApp] 302 GET / (172.18.0.1) 10.91ms
dev_1  | [W 14:48:27.699 LabApp] Could not determine jupyterlab build status without nodejs
dev_1  | [W 14:48:28.215 LabApp] 404 GET /lab/api/workspaces/lab?1616856507013 (172.18.0.1): Workspace 'lab' ('lab-a511') not found
dev_1  | [W 14:48:28.216 LabApp] Workspace 'lab' ('lab-a511') not found
dev_1  | [W 14:48:28.216 LabApp] 404 GET /lab/api/workspaces/lab?1616856507013 (172.18.0.1) 10.26ms referer=http://localhost:8080/lab?

좋은 느낌입니다!

localhost:8080



브라우저의 주소 표시줄에 localhost:8080을 입력하고 Enter.

Jupyter Lab이 열렸습니다! ! !



반자이! ! !

추가 : 씨발 무거운



어때?
파일 로드가 끝나지 않습니다.
무엇을 하는 것도 느리다.
어떻게 하면 좋을까.

좋은 웹페이지 즐겨찾기