Lab 9.3 - Managing Image Registry - Build an Image

1. Create hello-world directory

mkdir hello-world && cd hello-world

2. Create a Dockerfile file

vi Dockerfile
...
FROM registry.access.redhat.com/ubi8:8.0

RUN yum install -y --disableplugin=subscription-manager --nodocs nginx \
  && yum clean all

ADD index.html /usr/share/nginx/html

ADD nginxconf.sed /tmp/
RUN sed -i -f /tmp/nginxconf.sed /etc/nginx/nginx.conf

RUN touch /run/nginx.pid \
  && chgrp -R 0 /var/log/nginx /run/nginx.pid \
  && chmod -R g+rwx /var/log/nginx /run/nginx.pid

EXPOSE 8080
USER 1001

CMD nginx -g "daemon off;"
...

3. Create a index.html file

vi index.html
...
<html>
  <body>
    <h1>Hello World!</h1>
  </body>
</html>
...

4. Create a nginxconf.sed file

vi nginxconf.sed
...
s/listen       80/listen       8080/
s/listen       \[::\]:80/listen       \[::\]:8080/
s/user nginx;//
s%error_log /var/log/nginx/error.log%error_log stderr%
s%access_log  /var/log/nginx/access.log  main;%%
...

5. Ensure there are three files

ls -lah

6. Build the hello-world image

podman build -t hello-world .

7. Verify the image exist

podman images

Daftar Materi