Podmanでbuildするとエラーになった話

# はじめに

Podmanを2ヶ月ぶりくらいに使おうとして、`podman build`をしたらエラーを吐いたので解消方法を共有します。

# 環境

私のマシン及び、Podmanのバージョンは以下の通りです。

```cmd
% sw_vers
ProductName:    macOS
ProductVersion: 12.1
BuildVersion:   21C52

% brew info podman
podman: stable 3.4.4 (bottled), HEAD
Tool for managing OCI containers and pods
https://podman.io/
/usr/local/Cellar/podman/3.4.4 (170 files, 40.1MB) *
  Poured from bottle on 2022-02-03 at 14:49:46
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/podman.rb
License: Apache-2.0
==> Dependencies
Build: go ✘, go-md2man ✘
Required: qemu ✔
==> Options
--HEAD
        Install HEAD version
==> Caveats
zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Analytics
install: 16,027 (30 days), 38,851 (90 days), 92,921 (365 days)
install-on-request: 16,022 (30 days), 38,855 (90 days), 92,911 (365 days)
build-error: 1 (30 days)
```

# エラーの確認

今回は PostgreSQL の Client を立てたく、下記 Dockerfile を build しようとしたら問題が発生しました。

```Dockerfile:Dockerfile
FROM alpine:3.10
RUN apk --no-cache add postgresql-client bash
CMD ["/bin/bash"]
```

```cmd
% podman machine start
INFO[0000] waiting for clients...                       
INFO[0000] listening tcp://127.0.0.1:7777               
INFO[0000] new connection from  to /var/folders/81/1zq3g5b54zq2yycgpn8z398r0000gn/T/podman/qemu_podman-machine-default.sock 
Waiting for VM ...
Machine "podman-machine-default" started successfully
% podman build -t sqlclient .
Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman. failed to create sshClient: dial unix /private/tmp/com.apple.launchd.vUwC789Mrr/Listeners: connect: no such file or directory
```

あれ？エラー？
もしや他のコマンドも？？

```cmd
% podman ps
Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman. failed to create sshClient: dial unix /private/tmp/com.apple.launchd.vUwC789Mrr/Listeners: connect: no such file or directory
```

うわーーー

# 解消方法

OSのアップデートしたからか？？？
勘弁してくれーーーと思いつつ、色々とGitHubを探検すると[同じようなissue](https://github.com/containers/podman/issues/12728)を発見。

> It looks podman is trying to connect to the $SSH_AUTH_SOCK address but this is failing.
> Can you run `unset SSH_AUTH_SOCK` and try again.

ふむ。
Podmanは$SSH_AUTH_SOCKアドレスに接続しようとしているっぽいけど、失敗してるので`unset SSH_AUTH_SOCK`を実行して再度試せと。

```cmd
% unset SSH_AUTH_SOCK
```

再度ビルドする。

```cmd
% podman build -t sqlclient .
STEP 1/3: FROM alpine:3.10
STEP 2/3: RUN apk --no-cache add postgresql-client bash
--> Using cache 77aec76f98cd7a34bd819126b3dcc70503bbbf4e8af25a3e620839d6aba265d3
--> 77aec76f98c
STEP 3/3: CMD ["/bin/bash"]
--> Using cache 442b6809ad4cae89b3b070cbfdda046ee157d57be40fc589465cebc5383c5b5f
COMMIT sqlclient
--> 442b6809ad4
Successfully tagged localhost/sqlclient:latest
442b6809ad4cae89b3b070cbfdda046ee157d57be40fc589465cebc5383c5b5f
```

おおおお！ビルドできた！
念の為起動。

```cmd
% podman run -itd sqlclient             
a492786bd0143e2ac793f7760468d381089cfe83233aea5febb578d4f79477ee

% podman ps
CONTAINER ID  IMAGE                       COMMAND     CREATED         STATUS             PORTS       NAMES
a492786bd014  localhost/sqlclient:latest  /bin/bash   19 seconds ago  Up 19 seconds ago              crazy_wu

% podman exec -it a492786bd014 /bin/bash
bash-5.0# 
```

OKです！

同じような状況に陥っている方の助けになれば幸いです。