Skip to content

Commit c69a37c

Browse files
committed
Add docs for podman
1 parent 5c7fbb5 commit c69a37c

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed

Diff for: website/source/docs/provisioning/podman.html.md

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
---
2+
layout: "docs"
3+
page_title: "Podman - Provisioning"
4+
sidebar_current: "provisioning-podman"
5+
description: |-
6+
The Vagrant Podman provisioner can automatically install Podman, and run it as a drop in replacement for Docker.
7+
---
8+
9+
# Podman Provisioner
10+
11+
**Provisioner name: `"podman"`**
12+
13+
The Vagrant Podman provisioner can automatically install
14+
[Podman](https://www.podman.io) to be used as a drop in Docker replacement. This includes the ability to pull Docker containers, and configure certain containers to run on boot.
15+
16+
The podman provisioner is ideal for organizations that are using
17+
Podman as a means to manage and run their OCI images.
18+
19+
As with all provisioners, the Podman provisioner can be used along with
20+
all the other provisioners Vagrant has in order to setup your working
21+
environment the best way possible. For example, perhaps you use Puppet to
22+
install services like databases or web servers but use Podman to house
23+
your application runtime. You can use the Puppet provisioner along
24+
with the Podman provisioner.
25+
26+
## Options
27+
28+
The podman provisioner takes various options. None are required. If
29+
no options are provided, the Podman provisioner will only install Podman
30+
for you (if it is not already installed).
31+
32+
* `images` (array) - A list of images to pull using `podman pull`. You
33+
can also use the `pull_images` function. See the example below this
34+
section for more information.
35+
36+
In addition to the options that can be set, various functions are available
37+
and can be called to configure other aspects of the Podman provisioner. Most
38+
of these functions have examples in more detailed sections below.
39+
40+
* `build_image` - Build an image from a Dockerfile.
41+
42+
* `pull_images` - Pull the given images. This does not start these images.
43+
44+
* `post_install_provisioner` - A [provisioner block](/docs/provisioning) that runs post docker
45+
installation.
46+
47+
* `run` - Run a container and configure it to start on boot. This can
48+
only be specified once.
49+
50+
## Building Images
51+
52+
The provisioner can automatically build images. Images are built prior to
53+
any configured containers to run, so you can build an image before running it.
54+
Building an image is easy:
55+
56+
```ruby
57+
Vagrant.configure("2") do |config|
58+
config.vm.provision "podman" do |d|
59+
d.build_image "/vagrant/app"
60+
end
61+
end
62+
```
63+
64+
The argument to build an image is the path to give to `podman build`. This
65+
must be a path that exists within the guest machine. If you need to get data
66+
to the guest machine, use a synced folder.
67+
68+
The `build_image` function accepts options as a second parameter. Here
69+
are the available options:
70+
71+
* `args` (string) - Additional arguments to pass to `podman build`. Use this
72+
to pass in things like `-t "foo"` to tag the image.
73+
74+
## Pulling Images
75+
76+
The podman provisioner can automatically pull images from the
77+
Docker registry for you. There are two ways to specify images to
78+
pull. The first is as an array using `images`:
79+
80+
```ruby
81+
Vagrant.configure("2") do |config|
82+
config.vm.provision "podman",
83+
images: ["ubuntu"]
84+
end
85+
```
86+
87+
This will cause Vagrant to pull the "ubuntu" image from the registry
88+
for you automatically.
89+
90+
The second way to pull images is to use the `pull_images` function.
91+
Each call to `pull_images` will _append_ the images to be pulled. The
92+
`images` variable, on the other hand, can only be used once.
93+
94+
Additionally, the `pull_images` function cannot be used with the
95+
simple configuration method for provisioners (specifying it all in one line).
96+
97+
```ruby
98+
Vagrant.configure("2") do |config|
99+
config.vm.provision "podman" do |d|
100+
d.pull_images "ubuntu"
101+
d.pull_images "vagrant"
102+
end
103+
end
104+
```
105+
106+
## Running Containers
107+
108+
In addition to pulling images, the Podman provisioner can run and start
109+
containers for you. This lets you automatically start services as part of
110+
`vagrant up`.
111+
112+
Running containers can only be configured using the Ruby block syntax with
113+
the `do...end` blocks. An example of running a container is shown below:
114+
115+
```ruby
116+
Vagrant.configure("2") do |config|
117+
config.vm.provision "podman" do |d|
118+
d.run "rabbitmq"
119+
end
120+
end
121+
```
122+
123+
This will `podman run` a container with the "rabbitmq" image. Note that
124+
Vagrant uses the first parameter (the image name by default) to override any
125+
settings used in a previous `run` definition. Therefore, if you need to run
126+
multiple containers from the same image then you must specify the `image`
127+
option (documented below) with a unique name.
128+
129+
In addition to the name, the `run` method accepts a set of options, all optional:
130+
131+
* `image` (string) - The image to run. This defaults to the first argument
132+
but can also be given here as an option.
133+
134+
* `cmd` (string) - The command to start within the container. If not specified,
135+
then the container's default command will be used, such as the
136+
"CMD" command [specified in the `Dockerfile`](https:/docs.docker.io/en/latest/use/builder/#cmd).
137+
138+
* `args` (string) - Extra arguments for `podman run` (same as the extra arguments that can be specified for [`docker run`](https:/docs.docker.io/en/latest/commandline/cli/#run))
139+
on the command line. These are raw arguments that are passed directly to Podman.
140+
141+
* `auto_assign_name` (boolean) - If true, the `--name` of the container will
142+
be set to the first argument of the run. By default this is true. If the
143+
name set contains a "/" (because of the image name), it will be replaced
144+
with "-". Therefore, if you do `d.run "foo/bar"`, then the name of the
145+
container will be "foo-bar".
146+
147+
* `daemonize` (boolean) - If true, the "-d" flag is given to `podman run` to
148+
daemonize the containers. By default this is true.
149+
150+
* `restart` (string) - The restart policy for the container. Defaults to
151+
"always"
152+
153+
For example, here is how you would configure Podman to run a container
154+
with the Vagrant shared directory mounted inside of it:
155+
156+
```ruby
157+
Vagrant.configure("2") do |config|
158+
config.vm.provision "podman" do |d|
159+
d.run "ubuntu",
160+
cmd: "bash -l",
161+
args: "-v '/vagrant:/var/www'"
162+
end
163+
end
164+
```
165+
166+
In case you need to run multiple containers based off the same image, you can do
167+
so by providing different names and specifying the `image` parameter to it:
168+
169+
```ruby
170+
Vagrant.configure("2") do |config|
171+
config.vm.provision "podman" do |d|
172+
d.run "db-1", image: "user/mysql"
173+
d.run "db-2", image: "user/mysql"
174+
end
175+
end
176+
```

0 commit comments

Comments
 (0)