Podman Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(26 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* https://docs.podman.io/en/latest/Commands.html
=Internal=
=Internal=
* [[Podman#Subjects|Podman]]
* [[Podman#Subjects|Podman]]
=Installation=
=Installation=
==Mac==
==Mac==
Line 16: Line 17:
podman --version
podman --version
</syntaxhighlight>
</syntaxhighlight>
=VM Initialization=
=Podman Virtual Machine Operations=
 
==<span id='VM_Initialization'></span>Podman Virtual Machine Initialization==
{{External|https://docs.podman.io/en/latest/markdown/podman-machine-init.1.html#}}
{{External|https://docs.podman.io/en/latest/markdown/podman-machine-init.1.html#}}
Podman on MacOS requires a virtual machine. This is because containers must run with a Linux kernel, and the Podman virtual machine provides that kernel.  
Podman on MacOS requires a virtual machine. This is because containers must run with a Linux kernel, and the Podman virtual machine provides that kernel.  
Line 26: Line 29:
For more details, see {{Internal|Podman_Concepts#Podman_Virtual_Machine|Podman Virtual Machine}}
For more details, see {{Internal|Podman_Concepts#Podman_Virtual_Machine|Podman Virtual Machine}}


=VM Startup=
==<span id='https://kb.novaordis.com/index.php/Podman_Operations#VM_Startup'></span><span id='Podman_Virtual_Machine_Startup'></span>Start Virtual Machine==
{{External|https://docs.podman.io/en/latest/markdown/podman-machine-start.1.html}}
{{External|https://docs.podman.io/en/latest/markdown/podman-machine-start.1.html}}
Once the VM is [[#VM_Initialization|initialized]], it must be stared with:
Once the VM is [[#VM_Initialization|initialized]], it must be stared with:
Line 32: Line 35:
podman machine start
podman machine start
</syntaxhighlight>
</syntaxhighlight>
 
===Install System Helper===
==Install System Helper==
<font color=darkkhaki>
<font color=darkkhaki>
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:
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 /opt/brew/Cellar/podman/4.2.1/bin/podman-mac-helper install
  sudo /opt/brew/Cellar/podman/4.2.1/bin/podman-mac-helper install
  podman machine stop; podman machine start
  podman machine stop; podman machine start
This solved this issue:
podman build -f common/docker/Dockerfile [...]
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: connection to bastion host (ssh://core@localhost:61201/run/user/501/podman/podman.sock) failed: dial tcp [::1]:61201: connect: connection refused
You can still connect Docker API clients by setting DOCKER_HOST using the following command in your terminal session:
You can still connect Docker API clients by setting DOCKER_HOST using the following command in your terminal session:
  export DOCKER_HOST='unix:///Users/ovidiu/.local/share/containers/podman/machine/podman-machine-default/podman.sock'
  export DOCKER_HOST='unix:///Users/ovidiu/.local/share/containers/podman/machine/podman-machine-default/podman.sock'
</font>
</font>
===<tt>Error: qemu exited unexpectedly with exit code 1, stderr: qemu-system-x86_64: cannot create PID file: Cannot lock pid file: Resource temporarily unavailable</tt>===
To get around this, kill <code>qemu</code> and re-start the machine:
<syntaxhighlight lang='bash'>
ps -ef | grep qemu
kill -9 <qemu-pid>
podman machine start
</syntaxhighlight>
==Stop Virtual Machine==
<syntaxhighlight lang='bash'>
podman machine stop
</syntaxhighlight>
==Remove a Virtual Machine==
<syntaxhighlight lang='bash'>
podman machine rm
</syntaxhighlight>
==Display Virtual Machine Information==
<syntaxhighlight lang='bash'>
podman machine info
</syntaxhighlight>
==Inspect a Virtual Machine==
<syntaxhighlight lang='bash'>
podman machine inspect
</syntaxhighlight>
==List Virtual Machines==
<syntaxhighlight lang='bash'>
podman machine list
</syntaxhighlight>
==Configure a Virtual Machine==
<syntaxhighlight lang='bash'>
podman machine set
</syntaxhighlight>
==ssh Into a Virtual Machine==
<syntaxhighlight lang='bash'>
podman machine ssh
</syntaxhighlight>
=Podman Image Operations=
==Pull an Image from a Registry==
<syntaxhighlight lang='bash'>
podman pull docker.someorg.com/some-department/some-image:0.1.0
</syntaxhighlight>
The image will be cached locally and can be listed with <code>[[#podman_images|podman images]]</code>
==<span id='podman_images'></span>List Local Images==
<syntaxhighlight lang='bash'>
podman images
</syntaxhighlight>
==<span id='podman_images'></span>Remove Images from Local Storage==
<syntaxhighlight lang='bash'>
podman rmi [-f] <image-id>
</syntaxhighlight>


=Build Container Images=
==Build Container Images==
{{Internal|Build Container Images with podman|Build Container Images with podman}}
{{Internal|Build Container Images with podman|Build Container Images with podman}}
=Podman Container Operations=
==Run a Container==
{{Internal|Docker_run|<tt>docker run</tt>}}
<syntaxhighlight lang='bash'>
podman run -it [--rm] --entrypoint bash <some-image>
</syntaxhighlight>
==Get a Container ID==
<syntaxhighlight lang='bash'>
podman ps --filter "name=dev-consul" --format "{{.ID}}"
</syntaxhighlight>
More details on <code>--filter</code>: https://docs.podman.io/en/stable/markdown/podman-ps.1.html#filter-f
=Troubleshooting=
https://www.redhat.com/sysadmin/container-permission-denied-errors

Latest revision as of 21:23, 6 October 2023

External

Internal

Installation

Mac

brew install podman

Linux

dnf install -y podman && dnf clean all
podman --version

Version

podman --version

Podman Virtual Machine Operations

Podman Virtual Machine Initialization

https://docs.podman.io/en/latest/markdown/podman-machine-init.1.html#

Podman on MacOS requires a virtual machine. This is because containers must run with a Linux kernel, and the Podman virtual machine provides that kernel.

podman machine init

initializes a new Linux VM where the containers are run.

For more details, see

Podman Virtual Machine

Start Virtual Machine

https://docs.podman.io/en/latest/markdown/podman-machine-start.1.html

Once the VM is initialized, it must be stared with:

podman machine start

Install System Helper

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 /opt/brew/Cellar/podman/4.2.1/bin/podman-mac-helper install
podman machine stop; podman machine start

This solved this issue:

podman build -f common/docker/Dockerfile [...]
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: connection to bastion host (ssh://core@localhost:61201/run/user/501/podman/podman.sock) failed: dial tcp [::1]:61201: connect: connection refused

You can still connect Docker API clients by setting DOCKER_HOST using the following command in your terminal session:

export DOCKER_HOST='unix:///Users/ovidiu/.local/share/containers/podman/machine/podman-machine-default/podman.sock'

Error: qemu exited unexpectedly with exit code 1, stderr: qemu-system-x86_64: cannot create PID file: Cannot lock pid file: Resource temporarily unavailable

To get around this, kill qemu and re-start the machine:

ps -ef | grep qemu
kill -9 <qemu-pid>
podman machine start

Stop Virtual Machine

podman machine stop

Remove a Virtual Machine

podman machine rm

Display Virtual Machine Information

podman machine info

Inspect a Virtual Machine

podman machine inspect

List Virtual Machines

podman machine list

Configure a Virtual Machine

podman machine set

ssh Into a Virtual Machine

podman machine ssh

Podman Image Operations

Pull an Image from a Registry

podman pull docker.someorg.com/some-department/some-image:0.1.0

The image will be cached locally and can be listed with podman images

List Local Images

podman images

Remove Images from Local Storage

podman rmi [-f] <image-id>

Build Container Images

Build Container Images with podman

Podman Container Operations

Run a Container

docker run
podman run -it [--rm] --entrypoint bash <some-image>

Get a Container ID

podman ps --filter "name=dev-consul" --format "{{.ID}}"

More details on --filter: https://docs.podman.io/en/stable/markdown/podman-ps.1.html#filter-f

Troubleshooting

https://www.redhat.com/sysadmin/container-permission-denied-errors