diff --git a/Creating_Accessing-Containers_Networking b/Creating_Accessing-Containers_Networking new file mode 100644 index 0000000000..2524fe039b --- /dev/null +++ b/Creating_Accessing-Containers_Networking @@ -0,0 +1,32 @@ +Lab 1 -- Creating Containers +podman pull registry.access.redhat.com/ubi8/ubi-minimal:8.8 +podman images +podman run registry.access.redhat.com/ubi8/ubi-minimal:8.8 echo 'Hello Red Hat' +podman ps +podman run -e GREET=Hello -e NAME='Red Hat' registry.access.redhat.com/ubi8/ubi-minimal:8.8 printenv GREET NAME +podman run -d -p 8080:8080 registry.access.redhat.com/ubi8/httpd-24 +podman stop (id) +podman ps -a +podman rm (id) +podman rmi (id) + +Lab 2 -- Container Networking +podman network inspect podman +podman network create cities +podman network inspect cities +podman run --name times-app --network cities -p 8080:8080 -d docker.io/tsrana1/podman-info-times:v0.1 +podman inspect times-app -f '{{.NetworkSettings.Networks.cities.IPAddress}}' +podman run --rm --network cities registry.access.redhat.com/ubi8/ubi-minimal:8.5 curl -s http://IP_ADDRESS:8080/times/BKK +podman run --rm --network cities registry.access.redhat.com/ubi8/ubi-minimal:8.5 curl -s http://times-app:8080/times/BKK +podman run --name cities-app --network cities -p 8090:8090 -d -e TIMES_APP_URL=http://times-app:8080/times docker.io/tsrana1/podman-info-cities:v0.1 +curl http://localhost:8090/cities/MAD +curl http://localhost:8090/cities/SAN + +Lab 3 -- Accessing Containers +podman run --name nginx -d -p 8080:8080 docker.io/tsrana1/podman-nginx-helloworld +podman cp nginx:/var/log/nginx/error.log error.log +podman exec nginx ls /usr/share/nginx/html/public +podman cp nginx:/etc/nginx/nginx.conf nginx.conf +podman exec -it nginx bash +vim /etc/nginx/nginx.conf +podman exec nginx nginx -s reload diff --git a/Dockerfile.md b/Dockerfile.md new file mode 100644 index 0000000000..5209fe52fd --- /dev/null +++ b/Dockerfile.md @@ -0,0 +1,49 @@ +``` +# dockerfile to build image for JBoss EAP 6.4 + +# start from rhel 7.2 +FROM ubi8 + +# file author / maintainer +MAINTAINER "FirstName LastName" "emailaddress@gmail.com" + +# update OS +RUN yum -y update && \ +yum -y install sudo openssh-clients unzip java-1.8.0-openjdk-devel && \ +yum clean all + +# enabling sudo group +# enabling sudo over ssh +RUN echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \ +sed -i 's/.*requiretty$/Defaults !requiretty/' /etc/sudoers + +# add a user for the application, with sudo permissions +RUN useradd -m jboss ; echo jboss: | chpasswd ; usermod -a -G wheel jboss + +# create workdir +RUN mkdir -p /opt/jboss + +WORKDIR /opt/jboss + +# install JBoss EAP 6.4.0 +ADD jboss-eap-6.4.0.zip /opt/jboss/jboss-eap-6.4.0.zip +RUN unzip /opt/jboss/jboss-eap-6.4.0.zip +# set environment +ENV JBOSS_HOME /opt/jboss/jboss-eap-6.4 +# create JBoss console user +RUN $JBOSS_HOME/bin/add-user.sh admin admin@2016 --silent +# configure JBoss +RUN echo "JAVA_OPTS=\"\$JAVA_OPTS -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0\"" >> $JBOSS_HOME/bin/standalone.conf + +# set permission folder +RUN chown -R jboss:jboss /opt/jboss + +# JBoss ports +EXPOSE 8080 9990 9999 +# start JBoss +ENTRYPOINT $JBOSS_HOME/bin/standalone.sh-c standalone-full-ha.xml +USER jboss + +CMD /bin/bash + +``` diff --git a/EXAM.md b/EXAM.md new file mode 100644 index 0000000000..68e59cd92a --- /dev/null +++ b/EXAM.md @@ -0,0 +1,80 @@ +1 + +Edit the Docker file in path /home/openshift ex180 practice/EX180 as instructed below and build an image with name iboss-eap +Copy the file /home/openshift_ex180 _ practice/jboss-eap-6.4.0 .zip from host to container image path /opt/jboss/. Unzip the copied file. + +Set ENV for BOSS HOME to /opt/jboss/jboss-eap-6.4 +Create EAP user using $JBOSS_HOME/bin/add-user.sh admin admin@2016 --silent +Expose ports 8080,9990 and 9999 +Start JBOSS using $JBOSS_HOME/bin/standalone.sh-c standalone-full-ha.xml + + + +2 + +RUN container and use the image jboss-eap build in previous section. +Expose ports 8080 ,9990 and 9999 of containers to local host ports 8080,9990 and 9999 respectively. +Set name of the container as "jboss-eap-app" + + + +3 + +Get last 10 lines of logs for container jboss-eap-app +Stop the container boss-eap-app +Remove the container jboss-eap-app + + + +4 + +Add a tag "6.4.v1" to the image jboss-eap (Build in Test 1) +Save the image with new tag to tar file jboss-eap.6.4.v1.tar +Push the image with new tag "6.4.v1 to docker registry + + +5 + + +Run myg| container using Podman and image registry.access.redhat.com/rhscl/mysql-57-rhel7 +Name of the container mydb +Expose container port 3306 to port 30306 on local h +Pass the container parameter values +MYSQL_ROOT_PASSWORD=password +MYSQL_USER=user1 +MYSQL_PASSWORD=password +MYSQL_DATABASE=books + +6 + +Create an mysql application as instructed below +Name of the app is mysql-app + +Use image registry.access.redhat.com/rhscl/mysql-57-rhel7 + +Parameters to be +used MYSQL_USER=user MYSQL_PASSWORD=password MYSQL_DATABASE=books +All resources should have label "app=mydbapp" + +7 + +Expose the service to url "mysaltestapptesturl.com" +Copy file mytestfile. txt from host to the mysql application path /tmp/ +Check pod logs +Login into application and check the version of mysq| + +8 + +Create mysql application as instructed below +Use mysql.son or mysql.yaml for application creation   +Variable to be set   +MYSQL_USER=user1 MYSQL_PASSWORD=password MYSQL_DATABASE=books   + +9 + +Create Template from mysql. json or mysql. yaml file   +Create mysql application as instructed below   + • Use the template created   + • Variable to be set   +MYSQL_USER=user1 MYSQL_PASSWORD=password MYSQL_DATABASE=books   + diff --git a/README.md b/README.md index c2e6d90d35..9b09eeebd5 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,47 @@ # DO180-apps -DO180 Repository for Sample Applications +DO180 Repository for Sample Applications + +Dockerfile: +``` +# install JBoss EAP 6.4.0 +ADD jboss-eap-6.4.0.zip /opt/jboss/jboss-eap-6.4.0.zip +RUN unzip /opt/jboss/jboss-eap-6.4.0.zip +# set environment +ENV JBOSS_HOME /opt/jboss/jboss-eap-6.4 +# create JBoss console user +RUN $JBOSS_HOME/bin/add-user.sh admin admin@2016 --silent +# configure JBoss +RUN echo "JAVA_OPTS=\"\$JAVA_OPTS -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0\"" >> $JBOSS_HOME/bin/standalone.conf + +# set permission folder +RUN chown -R jboss:jboss /opt/jboss + +# JBoss ports +EXPOSE 8080 9990 9999 +# start JBoss +ENTRYPOINT $JBOSS_HOME/bin/standalone.sh -c standalone-full-ha.xml +``` + +sudo podman build -t jboss-eap . +sudo podman run -d --name jboss-eap-app -p 8080:8080 -p 9990:9990 -p 9999:9999 localhost/jboss-eap + +sudo podman logs --tail=10 jboss-eap-app +sudo podman stop jboss-eap-app +sudo podman ps -a +sudo podman rm jboss-eap-app + +sudo podman tag localhost/jboss-eap localhost/jboss-eap:6.4.v1 +sudo podman save -o localhost/jboss-eap.6.4.v1.tar localhost/jboss-eap:6.4.v1 +sudo podman images +sudo podman tag localhost/jboss-eap:6.4.v1 docker.io/haiduc2023/jboss-eap:6.4.v1 +sudo podman push docker.io/haiduc2023/jboss-eap:6.4.v1 + +sudo podman run -d --name mydb -v /home/student/local/mysql:/var/lib/mysql/data -p 30306:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_USER=user1 -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=books registry.access.redhat.com/rhscl/mysql-57-rhel7 +gedit mysql.sh +``` +#!/bin/bash + +sudo podman run -d --pod mypod --name mydb2 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_USER=user1 -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=books registry.access.redhat.com/rhscl/mysql-57-rhel7 +``` + +