0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Podman環境構築(Mac)

Posted at

概要

業務でPodmanを使用するため、公式を参考にMacで環境構築してみた(2024/10/15)

公式

Podmanとは

Red Hat社を中心とするコミュニティが開発している、Docker互換のコンテナエンジン

インストール(Mac)

[~/docker]
$ brew install podman
==> Auto-updating Homebrew..

[~/docker]
$ podman --version
podman version 5.2.2

コンテナを立てる

Podman の仮想マシンを作成

# 初期化
$ podman machine init
Looking up Podman Machine image at quay.io/podman/machine-os:5.2 to create VM
Getting image source signatures
Copying blob 2effca170b12 done   |
Copying config 44136fa355 done   |
Writing manifest to image destination
2effca170b1286030a1a35a3a4b99e94cdefa06844dc9d940b59672bd950f60a
Extracting compressed file: podman-machine-default-arm64.raw: done
Machine init complete
To start your machine run:

	podman machine start

仮想マシンstart

$ podman machine start
Starting machine "podman-machine-default"
...
Machine "podman-machine-default" started successfully

確認

$ podman ps
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES

サンプルコンテナ(Nginx)を作成

$ podman run --name basic_httpd -dt -p 8080:80/tcp docker.io/nginx
Trying to pull docker.io/library/nginx:latest...
...

# できた
$ podman ps
CONTAINER ID  IMAGE                           COMMAND               CREATED             STATUS             PORTS                         NAMES
e4645207fc9c  docker.io/library/nginx:latest  nginx -g daemon o...  About a minute ago  Up About a minute  0.0.0.0:8080->80/tcp, 80/tcp  basic_httpd

コマンド 説明
run コンテナ作成
--name コンテナ名指定
-d デタッチモード
-t ttyモード
-p ポート番号指定
docker.io/nginx イメージを指定 (docker.ioリポジトリにあるnginxイメージでコンテナを作成)

イメージ確認

# imageもインストールされてた
$ podman images
REPOSITORY               TAG         IMAGE ID      CREATED      SIZE
docker.io/library/nginx  latest      195245f0c792  6 weeks ago  197 MB

nginxが起動しているか確認

$ curl http://localhost:8080
<!DOCTYPE html>
<html>
<head>
...省略

ログ確認

$ podman logs basic_httpd
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
...
10.88.0.2 - - [24/Sep/2024:07:48:34 +0000] "GET / HTTP/1.1" 200 615 "-" "curl/8.7.1" "-"

止める

$ podman stop basic_httpd
basic_httpd

$ podman ps -a
CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS                    PORTS                         NAMES
e4645207fc9c  docker.io/library/nginx:latest  nginx -g daemon o...  5 minutes ago  Exited (0) 5 seconds ago  0.0.0.0:8080->80/tcp, 80/tcp  basic_httpd
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?