mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-02-07 09:18:59 +00:00
1 line
13 KiB
JSON
1 line
13 KiB
JSON
{"pageProps":{"metadata":{"date":"\"2021-06-10 11:51:26 +08:00\"","date_modified":"\"2021-07-20 23:31:29 +08:00\"","language":"en","source":""},"title":"Command line: Podman","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"configuring-to-include-dockerio"},"children":[{"type":"text","value":"Configuring to include "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"docker.io"}]}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.podman#configuring-to-include-dockerio"},"children":[{"type":"text","value":"Configuring to include docker.io"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"subcommands"},"children":[{"type":"text","value":"Subcommands"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.podman#subcommands"},"children":[{"type":"text","value":"Subcommands"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"examples"},"children":[{"type":"text","value":"Examples"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.podman#examples"},"children":[{"type":"text","value":"Examples"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"quickstart-for-pushing-a-container"},"children":[{"type":"text","value":"Quickstart for pushing a container"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.podman#quickstart-for-pushing-a-container"},"children":[{"type":"text","value":"Quickstart for pushing a container"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"interactive-selection-of-removing-images"},"children":[{"type":"text","value":"Interactive selection of removing images"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.podman#interactive-selection-of-removing-images"},"children":[{"type":"text","value":"Interactive selection of removing images"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"interactive-image-search-and-install"},"children":[{"type":"text","value":"Interactive image search and install"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.podman#interactive-image-search-and-install"},"children":[{"type":"text","value":"Interactive image search and install"}]}]}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Podman is a daemonless container engine.\nIt was also designed to be a drop-in replacement for Docker with similar command-line interface and everything.\nThus, it is also compatible with Docker images and configurations (i.e., Dockerfiles).\n"}]},{"type":"element","tagName":"h1","properties":{"id":"configuring-to-include-dockerio"},"children":[{"type":"text","value":"Configuring to include "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"docker.io"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"By default, Podman focuses on making the user concious about multiple registries outside DockerHub.\nThus, it doesn't have any by default.\nYou have to configure it first.\nFor more information, see the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"podman.1"}]},{"type":"text","value":" manual page and the linked pages.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's an incredibly simple example configuration that includes DockerHub.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-toml"]},"children":[{"type":"text","value":"unqualified-search-registries = ['docker.io']\n"}]}]},{"type":"element","tagName":"h1","properties":{"id":"subcommands"},"children":[{"type":"text","value":"Subcommands"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Podman has Git-style command-line interface with subcommands and exclusive options.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"build"}]},{"type":"text","value":" is for building images from the configuration — e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"podman build ."}]},{"type":"text","value":" will build an image from the current directory with the Dockerfile.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-t, --tag [NAME]"}]},{"type":"text","value":" attaches a tag to the image.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-f, --file [FILE]"}]},{"type":"text","value":" sets the name of the Dockerfile to be built from.\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"run"}]},{"type":"text","value":" will create a container from an image.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-d, --detach"}]},{"type":"text","value":" will make the process run in the background.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-it"}]},{"type":"text","value":" will make an interactive shell.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-p, --publish"}]},{"type":"text","value":" exposes the port of the image to the host.\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"tag"}]},{"type":"text","value":" will tag an existing image.\n Useful for correcting tags for pushing into a remote registry.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"image"}]},{"type":"text","value":" is anything about interaction with images.\n In fact, a lot of the subcommands presented so far are aliases with "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"image"}]},{"type":"text","value":" being the original — e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"image tag"}]},{"type":"text","value":" vs "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"tag"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"image pull"}]},{"type":"text","value":" vs "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"pull"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"image rm"}]},{"type":"text","value":" vs "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"rmi"}]},{"type":"text","value":".\n"}]}]}]},{"type":"element","tagName":"h1","properties":{"id":"examples"},"children":[{"type":"text","value":"Examples"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Podman is a big tool so it needs a big list of examples.\n"}]},{"type":"element","tagName":"h2","properties":{"id":"quickstart-for-pushing-a-container"},"children":[{"type":"text","value":"Quickstart for pushing a container"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As with big tools, comes with a big quickstart.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"# Builds an image from the Dockerfile of the current directory.\npodman build --tag todo-list-web-app .\n\n# List the images to see if our app image has been built.\npodman image list\n\n# Assuming the app creates an HTTP server at port 5000, we'll expose it to the host, making it accessible from there.\npodman run -d -p 5111:5000 todo-list-web-app\n\n# See if we did run a containerized version of our app.\npodman container list\n\n# Tag the image with the convention seen in Docker registry.\npodman tag foodogsquared/python-helloworld:v1.0.0\n\n# Push the image to the Docker registry (assuming you've already logged in to Docker registry).\npodman push foodogsquared/python-helloworld\n"}]}]},{"type":"element","tagName":"h2","properties":{"id":"interactive-selection-of-removing-images"},"children":[{"type":"text","value":"Interactive selection of removing images"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"What would be an example script without something like "},{"type":"element","tagName":"a","properties":{"href":"/cli.fzf"},"children":[{"type":"text","value":"fzf"}]},{"type":"text","value":"?\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"podman image list --format \"{{.ID}} {{.Repository}} {{.Tag}}\" \\\n | fzf --multi --prompt \"Choose images to remove > \" \\\n | awk '{print $1}' \\\n | xargs podman image rm\n"}]}]},{"type":"element","tagName":"h2","properties":{"id":"interactive-image-search-and-install"},"children":[{"type":"text","value":"Interactive image search and install"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Yes, another one with fzf...\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"podman image search --format \"{{.Index}} {{.Name}}\" alpine \\\n | fzf --multi --prompt \"Choose images to install > \" \\\n | awk '{print $2}' \\\n | xargs podman image pull\n"}]}]}]},"backlinks":[]},"__N_SSG":true} |