皆さん、Docker Desktopを使ったことがありますか?
はじめに
Dockerを使うことで、1台のサーバー上に複数のアプリケーション実行環境(Dockerコンテナ)を作成・利用できるようになります。
アプリケーション実行環境(Dockerコンテナ)の他サーバーなどへの移転、他ユーザーとの共有が簡単に実行できるようになります。
しかし、Docker Desktopを商用利用する際は有料となってしまう可能性があります。
そこで、Docker Desktopの代替を利用することで、料金のことを気にせずに使用できないか検討してみました。
今回利用したPodman Desktopは、そのままではdockerコマンドとして使用することができなかったため、Docker Desktopと同様に利用できるように設定しました。開発環境
Podman Desktopのインストール
brew install podman-desktop
brew install docker-compose
ln -s /usr/local/bin/podman /usr/local/bin/docker
readlink /usr/local/bin/docker
# /usr/local/bin/podman
docker ps -a
# 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 socket: failed to connect: dial tcp 127.0.0.1:50950: connect: connection refused
docker system connection list
# Name URI Identity Default
# podman-machine-default ssh://core@127.0.0.1:50950/run/user/501/podman/podman.sock /Users/[ユーザー名]/.ssh/podman-machine-default true
# podman-machine-default-root ssh://root@127.0.0.1:50950/run/podman/podman.sock /Users/[ユーザー名]/.ssh/podman-machine-default false
docker machine init
# Error: podman-machine-default: VM already exists
docker machine start
# Starting machine "podman-machine-default"
# Waiting for VM ...
# Mounting volume... /Users:/Users
# Mounting volume... /private:/private
# Mounting volume... /var/folders:/var/folders
#
# This machine is currently configured in rootless mode. If your containers
# require root permissions (e.g. ports < 1024), or if you run into compatibility
# issues with non-podman clients, you can switch using the following command:
#
# podman machine set --rootful
#
# API forwarding listening on: /Users/[ユーザー名]/.local/share/containers/podman/machine/qemu/podman.sock
#
# The system helper service is not installed; the default Docker API socket
# address can't be used by podman. If you would like to install it run the
# following commands:
#
# sudo /usr/local/Cellar/podman/4.6.2/bin/podman-mac-helper install
# podman machine stop; podman machine start
#
# You can still connect Docker API clients by setting DOCKER_HOST using the
# following command in your terminal session:
#
# export DOCKER_HOST='unix:///Users/[ユーザー名]/.local/share/containers/podman/machine/qemu/podman.sock'
#
# Machine "podman-machine-default" started successfully
docker machine stop
# Waiting for VM to exit...
# Machine "podman-machine-default" stopped successfully
sudo /usr/local/Cellar/podman/4.6.2/bin/podman-mac-helper install
CentOS 7 のイメージを取得し、Bashコマンド待ち受け状態にする
docker pull centos:centos7
# Resolved "centos" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
# Trying to pull quay.io/centos/centos:centos7...
# Getting image source signatures
# Copying blob sha256:2d473b07cdd5f0912cd6f1a703352c82b512407db6b05b43f2553732b55df3bc
# Copying config sha256:8652b9f0cb4c0599575e5a003f5906876e10c1ceb2ab9fe1786712dac14a50cf
# Writing manifest to image destination
# 8652b9f0cb4c0599575e5a003f5906876e10c1ceb2ab9fe1786712dac14a50cf
docker images
# REPOSITORY TAG IMAGE ID CREATED SIZE
# quay.io/centos/centos centos7 8652b9f0cb4c 2 years ago 212 MB
docker run -it -d --name centos7 centos:centos7
# 13d2472b75b8d264474ea7c06cc6332263edd38af2cf405b0d292d2061799158
docker start centos7
# centos7
docker ps
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
# 13d2472b75b8 quay.io/centos/centos:centos7 /bin/bash 32 seconds ago Up 31 seconds centos7
docker exec -it centos7 /bin/bash
cat /etc/redhat-release
# CentOS Linux release 7.9.2009 (Core)