DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Podman Notes


Installation

Install podman on CentOS 7+: yum install podman.

Install Podman on Mint 20

List all available versions:

https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/

And get version ID is 20.04.

export VERSION_ID=20.04
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
sudo apt-get update
sudo apt-get -y upgrade 
sudo apt-get -y install podman fuse-overlayfs
podman run hello-world    # verify

Note:

  • Mint 19 中 /etc/os-release 的 VERSION_ID 值为 19,需要手工改为 Ubuntu 的版本 18.04, 但运行 podman info 后卡住,无法使用。

  • 删除掉 {VERSION_ID} 大括号前面的反斜杠(如果有的话),否则会报资源找不到错误。

Usage

Start container with shared folder

Create a shared folder with --mount option:

podman search pacvim
# start a isolated container:
podman login -u leechau -p xxx registry.gitlab.com  # when a contaner is private
podman run -it registry.gitlab.com/leechau/workenv
# start a container with shared folder:
mkdir work    # the src folder must exists, while the target folder need not exists:
podman run -it --name work --mount src="$(pwd)/work",target="/home/leo/docs/work",type=bind registry.gitlab.com/leechau/workenv
# now in the container:
sudo chown -R leo:leo ~leo/docs
# save files in ~/docs/work then quit the container
podman diff work
podman start -ai work    # reatach to the container after logout

When a container is running, run a command outside:

podman exec work apt list    # run a non-interactive command
podman exec -u root work cat /root/.profile

Manage services

podman run -d -p 5001:5001 --name bms leechau/bookmarkserver:0.1.2
podman stop bms
podman ps -a
podman start bms

通过 -v 参数将配置文件装载到容器的指定位置(目标文件夹不需要已存在), 从而实现在容器运行时加载配置文件:

pd run -it --rm -v ~/Documents/algo/server.yml:/algo/server.yml registry.gitlab.com/leechau/workenv:0.2.0


Published

Oct 26, 2020

Last Updated

Oct 26, 2020

Category

Tech

Tags

  • container 1
  • podman 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor