Podman is a drop in replacement for Docker, and can handle containers daemonless and rootless ("ruthless"?). Containers work based on cgroups, namespaces and IPC, which is existing in Linux, and therefore requires a linux system to support it (which is based on Fedora CoreOS, and runs in QEMU).
Much of the configuration depends on the existence of 'brew' on OSX. If you haven't got brew (homebrew) installed, you can do so using:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
In order to run the podman machine, the podman software needs to be installed (step 1), a virtual machine for running podman on linux needs to be created (step 2), and run (step 3).
brew install podman
2.Initialize podman machine
podman machine init
3.Start podman machine
podman machine start
Because the podman machine must run before it can run containers, it is useful to understand if the podman machine is running. This is done with 'podman machine list':
podman machine list
NAME VM TYPE CREATED LAST UP CPUS MEMORY DISK SIZE podman-m* qemu 17 hours ago Currently running 1 2.147GB 10.74GB
podman machine list
NAME VM TYPE CREATED LAST UP CPUS MEMORY DISK SIZE podman-m* qemu 17 hours ago 3 seconds ago 1 2.147GB 10.74GB
This setup is ideal for developers who want an easy way to setup YugabyteDB without all the hassle of configuration.
Any type of work with podman with containers requires the podman machine to be running. The podman machine is what actually performs the container commands.
For any type of coordinated work it's important to select a version to work on for the software you are using. Using the latest version can be a different version in time, and can cause version sprawl, so I would strongly recommend always choosing a specific version.
Obtain the yugabyte docker versions available:
curl -L -s 'https://registry.hub.docker.com/v2/repositories/yugabytedb/yugabyte/tags?page_size=5' | jq '."results"["name"]'
"188.8.131.52-b10" "184.108.40.206-b7" "220.127.116.11-b16" "18.104.22.168-b10" "22.214.171.124-b37"
Please mind the jq executable is not installed by default on OSX, but can easily be installed using brew:
brew install jq
From the above versions, choose one to use, and obtain the image of the selected version in the following way:
podman pull yugabytedb/yugabyte:126.96.36.199-b7
Resolving "yugabytedb/yugabyte" using unqualified-search registries (/etc/containers/registries.conf.d/999-podman-machine.conf) Trying to pull docker.io/yugabytedb/yugabyte:188.8.131.52-b7... Getting image source signatures Copying blob sha256:486c41cfe6bf41372e1fbbe5e644b65e27a0d088135dbd3989721cb251147731 ...snipped for brevety... Copying blob sha256:ea30bbe39b88dfca4bdc2353505ea36c9322b8e9e17f969a0aedb1f058969f88 Copying config sha256:4f1f8156a955f434215a6f8ed01d782d61179c7624cc82a300c2f111c4fa7b51 Writing manifest to image destination Storing signatures 4f1f8156a955f434215a6f8ed01d782d61179c7624cc82a300c2f111c4fa7b51
Now a container can be started from the downloaded image:
podman run -d --name yugabyte-2.11 -p5433:5433 -p7000:7000 -p9000:9000 yugabytedb/yugabyte:184.108.40.206-b7 bin/yugabyted start --base_dir=/home/yugabyte/yb_data --daemon=false
This takes a few moments to start.
When it has been started, the container and its status can be validated using podman ps:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 701422c063b4 ../yugabyte:220.127.116.11-b7 bin/yugabyted sta... 37 seconds ago Up 36 seconds ago 0.0.0.0:5433->5433/tcp, 0.0.0.0:7000->7000/tcp, 0.0.0.0:9000->9000/tcp yugabyte-2.11
If the container was successfully started, it will say 'Up' with the status. Also mind the name, which is important if you have got more than one container running.
One issue I found was that port 7000 was taken, which prevented the container from starting, because it wanted to use port 7000 on localhost. This was caused by: (OSX) system preferences>sharing>airplay-receiver, which is checked by default and needs to be unchecked.
After the container has started, it can be accessed from the CLI in the following way:
podman exec -it yugabyte-2.11 bash
This allows you to investigate logfiles, process statuses, etc.
Stop the yugabyte container:
podman stop yugabyte-2.11
Restart the yugabyte container:
podman restart yugabyte-2.11
Please be aware that the yugabyte container must be stopped prior to stopping the podman machine. The podman machine might need to be stopped if no containers need running, and will be stopped if Mac is going to be turned off or restarted. If the yugabyte container is not stopped, it will leave a file in place indicating that yugabyte YSQL is running, which will prevent YSQL from starting up if the container is started again.
During the setup above, the podman machine has been initialized and is ready for use. After a host reboot, the podman machine doesn't need to be initialized again. However, the podman machine must be started after a reboot, it isn't started automatically:
podman machine start
Once the podman machine is started, you can query the container statuses. By default containers are not automatically started on podman machine startup. To query the status of the containers including non-running containers, use the '--all' flag:
podman ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 701422c063b4 ../yugabyte:18.104.22.168-b7 bin/yugabyted sta... 2 hours ago Exited (0) 10 minutes ago 0.0.0.0:5433->5433/tcp, 0.0.0.0:7000->7000/tcp, 0.0.0.0:9000->9000/tcp yugabyte-2.11
This shows that our yugabyte-2.11 container still is there, but it is not running. In order to use it, start the container:
podman start yugabyte-2.11
If we run podman ps again, we can validate the container is now running:
podman ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 701422c063b4 ../yugabyte:22.214.171.124-b7 bin/yugabyted sta... 2 hours ago Up 40 seconds ago 0.0.0.0:5433->5433/tcp, 0.0.0.0:7000->7000/tcp, 0.0.0.0:9000->9000/tcp yugabyte-2.11
One way of using YSQL is to install postgresql on mac via brew (brew install postgresql). You can then run psql on the CLI directly to access YSQL in the container.
The database and its contents do survive stopping and starting the container, including if this has happened as part of a restart of the host. If a container is removed, the data is removed with it.
The podman machine running in qemu can be stopped, and removed:
podman machine stop podman machine rm
If the podman machine is removed, all the containers it hosted are removed with it.
The podman files are stored in the following place:
~/.config podman machine configuration file
~/.local podman machine disk image
~/.ssh podman machine private and public key
Containers and their configuration are stored inside the podman machine.