# Containerization ## Genaral ## Usage ### Downloading container image ````{tabs} ```{code-tab} bash Podman podman pull : ``` ```{code-tab} bash Docker docker pull : ``` ```` `````{admonition} Example To download `python` image version `3.12-slim`: ````{tabs} ```{code-tab} bash Podman podman pull python:3.12-slim ``` ```{code-tab} bash Docker docker pull python:3.12-slim ``` ```` ````` ### Running a container To run container based on image `` with tag `` execute: ````{tabs} ```{code-tab} bash Podman podman run : ``` ```{code-tab} bash Docker docker run : ``` ```` `````{admonition} Example Run container based on `python` image version `3.12-slim`. ````{tabs} ```{code-tab} bash Podman podman run python:3.12-slim ``` ```{code-tab} bash Docker docker run python:3.12-slim ``` ```` ````` #### Name a container You can specify container name with `--name` option: ````{tabs} ```{code-tab} bash Podman podman run --name "" : ``` ```{code-tab} bash Docker docker run --name "" : ``` ```` `````{admonition} Example Run container based on `python` image version `3.12-slim` and name it `test_python_container`. ````{tabs} ```{code-tab} bash Podman podman run --name test_python_container python:3.12-slim ``` ```{code-tab} bash Docker docker run --name test_python_containerpython:3.12-slim ``` ```` ````` #### Execute a command inside a container ````{tabs} ```{code-tab} bash Podman podman run : ``` ```{code-tab} bash Docker docker run : ``` ```` `````{admonition} Example Get version of python (run `python --verion`) inside the container: ````{tabs} ```{code-tab} bash Podman podman run python:3.12-slim python --version ``` ```{code-tab} bash Docker docker run python:3.12-slim python --version ``` ```` ````` #### Enter container's CLI (command line interface): ````{tabs} ```{code-tab} bash Podman podman run -it : ``` ```{code-tab} bash Docker docker run -it : ``` ```` `````{admonition} Example enter `bash` CLI inside a `python` based container. ````{tabs} ```{code-tab} bash Podman podman run -it python:3.12-slim bash ``` ```{code-tab} bash Docker docker run -it python:3.12-slim bash ``` ```` ````` #### Expose container port: ````{tabs} ```{code-tab} bash Podman podman run -p : : ``` ```{code-tab} bash Docker docker run -p : : ``` ```` `````{admonition} Example App inside container is running on port `8888`. If you want to access this app outside container with `localhost:8880`: ````{tabs} ```{code-tab} bash Podman podman run -p 8880:8888 python:3.12-slim ``` ```{code-tab} bash Docker docker run -p 8880:8888 python:3.12-slim ``` ```` ````` ### Managing containers #### Display (list) running containers ````{tabs} ```{code-tab} bash Podman podman ps ``` ```{code-tab} bash Docker docker ps ``` ```` #### Display all containers This also displays exited (stopped) containers. ````{tabs} ```{code-tab} bash Podman podman ps -a ``` ```{code-tab} bash Docker docker ps -a ``` ```` ### Managing images #### Viewing locally available (downloaded) images ````{tabs} ```{code-tab} bash Podman podman images ``` ```{code-tab} bash Docker docker images ``` ```` ## Building a container To build a custom container image create a new folder create a `Dockerfile` file in that folder. (There can only be **one** `Dockerfile` file in any folder). #### Build an image ### Dockerfile ## Compose ### Compose file ### Usage