-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5ad3ae
commit 7d0cf65
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |