Skip to content

Commit

Permalink
podman build
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzheng422 committed Dec 30, 2024
1 parent d5ad3ae commit 7d0cf65
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions redhat/notes/2024/2024.12.podman.build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# podman build & ps

We build contaimer image using podman build, but sometimes we encounter issues with the build process that can cause the build to fail, sometimes the script in the dockerfile will write logfile to local directory which will be deleted or overwritten after the podman build exit.

To see the content of such log files generated during the build process, we need some tips to access the logs files. What we will do, is to run container using the intermediary cache image which is created during the build process, and access the logfile in the container.

```bash

mkdir -p /data/tmp

cd /data/tmp

# we create a dockerfile, which have multiple RUN
# each RUN will create an intermedary image layers
cat << EOF > Dockerfile
FROM docker.io/rockylinux:9
RUN echo 'test' > /tmp/wzh.test
RUN sleep 99999999
EOF

# during podman build, we can see the intermedary layers being created
podman build -t myimage:remove ./
# STEP 1/3: FROM docker.io/rockylinux:9
# STEP 2/3: RUN echo 'test' > /tmp/wzh.test
# --> 3fb515b1a25c
# STEP 3/3: RUN sleep 99999999

# no container created
podman ps -a
# nothing

# but the intermediary image has been created
podman image ls
# REPOSITORY TAG IMAGE ID CREATED SIZE
# <none> <none> 3fb515b1a25c 20 seconds ago 181 MB
# ......

# we can run a container from the intermediary image
# to access the logfile
podman run --rm 3fb515b1a25c cat /tmp/wzh.test
# test

```

# end

0 comments on commit 7d0cf65

Please sign in to comment.