Install Docker Engine on CentOS | Docker Documentation

 

Install Docker Engine on CentOS

 

docs.docker.com

 sudo yum install -y yum-utils
 sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
[root@localhost ~]# systemctl --now enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/                                    systemd/system/docker.service.


[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:fc6cf906cbfa013e80938cdf0bb199fbdbb86d6e3e013783e5a766f50f5dbce0
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
hello-world   latest    9c7a54a9a43c   13 days ago   13.3kB

Docker File

[root@localhost ~]# vi Dockerfile

FROM centos
MAINTAINER XG (xegota9@gmail.com)
RUN dnf -y install httpd
RUN echo "Test Web Server"> /var/www/html/index.html
EXPOSE 80
CMD ["-D","FOREGROUND"]
ENTRYPOINT ["/usr/bin/httpd"]

"Dockerfile" 7L, 188C

cmd(편집O), entrypoint(편집X,추가가능) : 컨테이너가 생성될 때 실행되는 명령어

[root@localhost ~]# docker build -t xg/centos-httpd:latest ./
[+] Building 3.9s (2/3)
 => [internal] load build definition from Dockerfile                                                                 0.0s
 => => transferring dockerfile: 227B                                                                                 0.0s
 => [internal] load .dockerignore                                                                                    0.0s
 => => transferring context: 2B                                                                                      0.0s
 => [internal] load metadata for docker.io/library/centos:latest
  => ERROR [2/3] RUN dnf -y install httpd                                                                             3.1s
------
 > [2/3] RUN dnf -y install httpd:
#0 2.739 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
#0 2.739 CentOS Linux 8 - AppStream                       58  B/s |  38  B     00:00
------
Dockerfile:3
--------------------
   1 |     FROM centos
   2 |     MAINTAINER XG (xegota9@gmail.com)
   3 | >>> RUN dnf -y install httpd
   4 |     RUN echo "Test Web Server"> /var/www/html/index.html
   5 |     EXPOSE 80
--------------------
ERROR: failed to solve: process "/bin/sh -c dnf -y install httpd" did not complete successfully: exit code: 1
[root@localhost ~]#

Centos는 리포지터리 지원이 종료되었다.(설치X)


[root@localhost ~]# vi Dockerfile

FROM rockylinux:8.7
MAINTAINER xg (xegota9@gmail.com)
RUN dnf -y install httpd
RUN echo "Test Web Server"> /var/www/html/index.html
EXPOSE 80
CMD ["-D","FOREGROUND"]
ENTRYPOINT ["/usr/sbin/httpd"]

"Dockerfile" 7L, 188C
[root@localhost ~]# docker build -t xg/rockylinux-httpd:2.0 ./
[+] Building 0.6s (2/3)
[+] Building 0.9s (2/3)
[+] Building 2.8s (7/7) FINISHED
 => [internal] load build definition from Dockerfile                                                                 0.0s
 => => transferring dockerfile: 237B                                                                                 0.0s
 => [internal] load .dockerignore                                                                                    0.0s
 => => transferring context: 2B                                                                                      0.0s
 => [internal] load metadata for docker.io/library/rockylinux:8.7                                                    1.5s
 => [1/3] FROM docker.io/library/rockylinux:8.7@sha256:68bef3459bbb8c33841575a7f71c4de94718b7bbd103fd0417a537395d40  0.0s
 => CACHED [2/3] RUN dnf -y install httpd                                                                            0.0s
 => [3/3] RUN echo "Test Web Server" > /var/www/html/index.html                                                      0.7s
 => exporting to image                                                                                               0.3s
 => => exporting layers                                                                                              0.2s
 => => writing image sha256:b7a424c969e955601314ab59268a4c5f82a11f751a526d522b47cec0fcaad88b                         0.0s
 => => naming to docker.io/xg/rockylinux-httpd:2.0                                                                   0.1s
[root@localhost ~]#
[root@localhost ~]# docker images
REPOSITORY            TAG       IMAGE ID       CREATED          SIZE
xg/rockylinux-httpd   2.0       b7a424c969e9   46 seconds ago   253MB
[root@localhost ~]# docker run -d -p 8082:80 xg/rockylinux-httpd:2.0
d428604d5a3892bc3b9d2690ad7e24c6163b620b0cac344a8efa530b1699a1ed

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                     COMMAND                   CREATED          STATUS          PORTS                                   NAMES
d428604d5a38   xg/rockylinux-httpd:2.0   "/usr/sbin/httpd -D …"   20 seconds ago   Up 18 seconds   0.0.0.0:8082->80/tcp, :::8082->80/tcp   romantic_euler

[root@localhost ~]# curl localhost:8082
Test Web Server

CMD와 ENTRYPOINT의 차이

[root@localhost ~]# mkdir CMD ETP
[root@localhost ~]# ls
[root@localhost ~]# cd CMD
[root@localhost CMD]#
[root@localhost CMD]#
[root@localhost CMD]#
[root@localhost CMD]# vi DockerFile
FROM centos:7
CMD ["echo", "hello, xg"]
"Dockerfile" 3L, 41C
[root@localhost CMD]# docker build -t hello:cmd .
[+] Building 9.6s (3/4)
 => [internal] load build definition from Dockerfile                                                                 0.0s
 => => transferring dockerfile: 78B                                                                                  0.0s
 => [internal] load .dockerignore                                                                                    0.0s
 => => transferring context: 2B                                                                                      0.0s
 => [internal] load metadata for docker.io/library/centos:7                                                          3.6s
 => [1/1] FROM docker.io/library/centos:7@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4    6.0s
 => => resolve docker.io/library/centos:7@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4    0.0s
 
 [root@localhost CMD]# docker run hello:cmd
hello, xg
[root@localhost CMD]# docker run hello:cmd echo soycrab
soycrab

[root@localhost ~]# cd ETP
[root@localhost ETP]# ls
[root@localhost ETP]# vi Dockerfile
FROM centos:7
ENTRYPOINT ["echo", "Hello, xg"]
"Dockerfile" 4L, 49C
[root@localhost ETP]# docker build -t hello:etp .
[+] Building 1.5s (5/5) FINISHED
 => [internal] load build definition from Dockerfile                                                                 0.0s
 => => transferring dockerfile: 86B                                                                                  0.0s
 => [internal] load .dockerignore                                                                                    0.0s
 => => transferring context: 2B                                                                                      0.0s
 => [internal] load metadata for docker.io/library/centos:7                                                          1.5s
 => CACHED [1/1] FROM docker.io/library/centos:7@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d64874  0.0s
 => exporting to image                                                                                               0.0s
 => => exporting layers                                                                                              0.0s
 => => writing image sha256:5288068d68354ac914ded5ce83ea68096c2fe0f5e08f5261cd861f4df44d0cd6                         0.0s
 => => naming to docker.io/library/hello:etp                                                                         0.0s
[root@localhost ETP]#
[root@localhost ETP]# docker run hello:etp
Hello, xg
[root@localhost ETP]# docker run hello:etp echo soycrab
Hello, xg echo soycrab

Maven

빌드를 위한 의존성과 여러가지 설정을 자동화 하는 도구

[root@localhost ~]# ls
4.3.1  4.3.2  CMD  Dockerfile  ETP  anaconda-ks.cfg
[root@localhost ~]#
[root@localhost ~]# cd 4.3.1
[root@localhost 4.3.1]# ls
Dockerfile  mvnw  pom.xml  src

[root@localhost 4.3.1]# vi Dockerfile
FROM openjdk:8
LABEL description="Echo IP Java Application"
EXPOSE 60431
COPY ./target/app-in-host.jar /opt/app-in-image.jar
WORKDIR /opt
ENTRYPOINT [ "java", "-jar", "app-in-image.jar" ]
"Dockerfile" [noeol] 6L, 187C
[root@localhost 4.3.1]# dnf -y install maven
마지막 메타자료 만료확인 0:30:26 이전인: 2023년 05월 18일 (목) 오전 11시 03분 23초.
종속성이 해결되었습니다.
====================================================================================================================
 꾸러미                                   구조    버전                                             레포지터리  크기
====================================================================================================================
설치 중:
 maven                                    noarch  1:3.5.4-5.module+el8.6.0+975+c0ed2db8            appstream   26 k
  xorg-x11-fonts-Type1-7.5-19.el8.noarch
완료되었습니다!

[root@localhost 4.3.1]#
[root@localhost 4.3.1]#
[root@localhost 4.3.1]# ./mvnw clean package
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.2.2.RELEASE/spring-boot-starter-parent-2.2.2.RELEASE.pom
Downloaded from central: https://repo.maven.apache.org/maven2/com/google/guava/guava/19.0/guava-19.0.jar (2.3 MB at 2.8 MB/s)
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  19.341 s
[INFO] Finished at: 2023-05-18T11:35:09+09:00
[INFO] ------------------------------------------------------------------------
[root@localhost 4.3.1]#
[root@localhost 4.3.1]# ll
합계 20
-rw-r--r-- 1 root root   187  5월 18 11:00 Dockerfile
-rwx------ 1 root root 10070  5월 18 11:00 mvnw
-rw-r--r-- 1 root root  1751  5월 18 11:00 pom.xml
drwxr-xr-x 3 root root    18  5월 18 11:00 src
drwxr-xr-x 6 root root   143  5월 18 11:35 target
[root@localhost 4.3.1]# docker build -t xg-img .
[+] Building 5.2s (4/7)
 => [internal] load build definition from Dockerfile                                                           0.0s
 => => transferring dockerfile: 226B                                                                           0.0s
 => [internal] load .dockerignore
 
 [root@localhost 4.3.1]# docker images
REPOSITORY            TAG       IMAGE ID       CREATED             SIZE
xg-img                latest    07b963cc94b0   25 seconds ago      544MB
[root@localhost 4.3.1]# docker build -t xg-img:1.0 -t xg-img:2.0 .
[+] Building 1.5s (8/8) FINISHED
 => [internal] load build definition from Dockerfile                 
 
 [root@localhost 4.3.1]# docker images
REPOSITORY            TAG       IMAGE ID       CREATED             SIZE
xg-img                1.0       07b963cc94b0   5 minutes ago       544MB
xg-img                2.0       07b963cc94b0   5 minutes ago       544MB
xg-img                latest    07b963cc94b0   5 minutes ago       544MB
[root@localhost 4.3.1]# sed -i 's/Application/Development/' Dockerfile
[root@localhost 4.3.1]# docker build -t xg-img:3.0 .
[+] Building 0.7s (8/8) FINISHED
 => [internal] load build definition from Dockerfile         
 [root@localhost 4.3.1]# docker images
REPOSITORY            TAG       IMAGE ID       CREATED             SIZE
xg-img                1.0       07b963cc94b0   8 minutes ago       544MB
xg-img                2.0       07b963cc94b0   8 minutes ago       544MB
xg-img                latest    07b963cc94b0   8 minutes ago       544MB
xg-img                3.0       4a808ab8e96f   8 minutes ago       544MB
[root@localhost 4.3.1]# docker run -d -p 30001:80 --name xghome --restart always xg-img
c601ac33cdbaacc46886af4957efa542b558c0defa919df79ad723d8835fa0d8
[root@localhost 4.3.1]# docker ps
CONTAINER ID   IMAGE                     COMMAND                   CREATED             STATUS             PORTS                                                NAMES
c601ac33cdba   xg-img                    "java -jar app-in-im…"   3 seconds ago       Up 1 second        60431/tcp, 0.0.0.0:30001->80/tcp, :::30001->80/tcp   xghome


삭제

[root@localhost 4.3.1]# docker rm -f xghome
xghome
[root@localhost 4.3.1]# docker rmi -f $(docker images -q xg-img)
Untagged: xg-img:3.0
Deleted: sha256:4a808ab8e96f6d8f3bce73a9a5ea360a89d346f28efac9837bd8d0fe25a5ddd6
Untagged: xg-img:1.0
Untagged: xg-img:2.0
Untagged: xg-img:latest

[root@localhost 4.3.1]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

 


이미지 경량화

[root@localhost 4.3.2]# ls
Dockerfile  build-in-host.sh  mvnw  pom.xml  src
[root@localhost 4.3.2]# vi Dockerfile

FROM gcr.io/distroless/java:8
LABEL description="Echo IP Java Application"
EXPOSE 80
COPY ./target/app-in-host.jar /opt/app-in-image.jar
WORKDIR /opt
ENTRYPOINT [ "java", "-jar", "app-in-image.jar" ]

"Dockerfile" [noeol] 6L, 202C
[root@localhost 4.3.2]# ./mvnw clean package
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< Stark.Industries:echo-ip-java >--------------------
[INFO] Building Ultron-PRJ 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ echo-ip-java ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ echo-ip-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Total time:  4.478 s
[INFO] Finished at: 2023-05-18T12:04:29+09:00
[INFO] ------------------------------------------------------------------------
[root@localhost 4.3.2]#
[root@localhost 4.3.2]# docker build -t build-in-host.sh ./
[+] Building 8.9s (8/8) FINISHED
 => [internal] load build definition from Dockerfile                                                           0.0s
 => => transferring dockerfile: 239B                                                                           0.0s
 => [internal] load .dockerignore                                                                              0.0s
 => => transferring context: 2B                                                                                0.0s
 => [internal] load metadata for gcr.io/distroless/java:8                                                      0.7s
 => [internal] load build context                                                                              0.2s
 => => transferring context: 17.60MB                                                                           0.2s
 => [1/3] FROM gcr.io/distroless/java:8@sha256:34c3598d83f0dba27820323044ebe79e63ad4f137b405676da75a3905a408a  7.9s
 => => resolve gcr.io/distroless/java:8@sha256:34c3598d83f0dba27820323044ebe79e63ad4f137b405676da75a3905a408a  0.0s
 => => sha256:34c3598d83f0dba27820323044ebe79e63ad4f137b405676da75a3905a408adf 1.08kB / 1.08kB                 0.0s
 => => sha256:b762aad6c0144f085989fc2f4b24cdd1a3940862899557a8936fac7645e66d42 1.16kB / 1.16kB                 0.0s
 => => sha256:60775238382ed8f096b163a652f5457589739d65f1395241aba12847e7bdc2a1 652.81kB / 652.81kB             0.5s
 => => sha256:8d239582974e6d64dcbc4cb99002943f7af883317dc16c9b19ab04b5b9b2c73d 7.33MB / 7.33MB                 1.7s
 => => sha256:e708be98c58f6bb27bf2b7839d7e63ad5be667b1585c6142af4d3dbbe80a7330 643.66kB / 643.66kB             0.7s
 => => extracting sha256:60775238382ed8f096b163a652f5457589739d65f1395241aba12847e7bdc2a1                      0.2s
 => => sha256:f17daab2ad826a35e2ad46bddc8f19719ad37d348a2213ab82041630a8ea21aa 4.55MB / 4.55MB                 1.6s
 => => sha256:7b76a28293bad4856f724babd976cc0d04e97bc08647a008e6f5373f33b6ffa8 39.72MB / 39.72MB               6.6s
 => => extracting sha256:8d239582974e6d64dcbc4cb99002943f7af883317dc16c9b19ab04b5b9b2c73d                      0.3s
 => => extracting sha256:e708be98c58f6bb27bf2b7839d7e63ad5be667b1585c6142af4d3dbbe80a7330                      0.0s
 => => extracting sha256:f17daab2ad826a35e2ad46bddc8f19719ad37d348a2213ab82041630a8ea21aa                      0.2s
 => => extracting sha256:7b76a28293bad4856f724babd976cc0d04e97bc08647a008e6f5373f33b6ffa8                      1.2s
 => [2/3] COPY ./target/app-in-host.jar /opt/app-in-image.jar                                                  0.2s
 => [3/3] WORKDIR /opt                                                                                         0.0s
 => exporting to image                                                                                         0.1s
 => => exporting layers                                                                                        0.1s
 => => writing image sha256:c38feafc2fcec159c6938d6159d8fecf01a4638d2010e113f1e21acfc0574588                   0.0s
 => => naming to docker.io/library/build-in-host.sh                                                            0.0s
[root@localhost 4.3.2]# docker images
REPOSITORY         TAG       IMAGE ID       CREATED          SIZE
build-in-host.sh   latest    c38feafc2fce   13 seconds ago   148MB
[root@localhost 4.3.2]# docker run -t -p 30002:80 --name xg-image --restart always build-in-host.sh

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)

2023-05-18 03:05:55.947  INFO 1 --- [           main] c.stark.Industries.UltronPRJApplication  : Starting UltronPRJApplication v0.0.1-SNAPSHOT on 3221bf0dfa46 with PID 1 (/opt/app-in-image.jar started by root in /opt)
2023-05-18 03:05:55.950  INFO 1 --- [           main] c.stark.Industries.UltronPRJApplication  : No active profile set, falling back to default profiles: default

[root@localhost 4.3.2]# docker run -d -p 30003:80 --name xg-images --restart always build-in-host.sh
4c82d7f90cd6c09725b1b98ed1034769baf547853764a4f4bd16c4ac4eef7b15
[root@localhost 4.3.2]# docker ps -a
CONTAINER ID   IMAGE              COMMAND                   CREATED              STATUS                         PORTS                                     NAMES
4c82d7f90cd6   build-in-host.sh   "java -jar app-in-im…"   About a minute ago   Up About a minute              0.0.0.0:30003->80/tcp, :::30003->80/tcp   xg-images
3221bf0dfa46   build-in-host.sh   "java -jar app-in-im…"   6 minutes ago        Exited (130) 4 minutes ago                                               xg-image

[root@localhost 4.3.2]# curl 127.0.0.1:30003
src: 172.17.0.1 / dest: 127.0.0.1

이미지 컨테이너 내부에서 빌드

[root@localhost ~]# cd 4.3.3
[root@localhost 4.3.3]#
[root@localhost 4.3.3]# ls
Dockerfile
[root@localhost 4.3.3]# vi Dockerfile
FROM openjdk:8
LABEL description="Echo IP Java Application"
EXPOSE 60433
RUN git clone https://github.com/iac-source/inbuilder.git
WORKDIR inbuilder
RUN chmod 700 mvnw
RUN ./mvnw clean package
RUN mv target/app-in-host.jar /opt/app-in-image.jar
WORKDIR /opt
ENTRYPOINT [ "java", "-jar", "app-in-image.jar" ]

"Dockerfile" [noeol] 10L, 307C
[root@localhost 4.3.3]# docker build -t build ./
[+] Building 15.8s (7/10)
 => [internal] load build definition from Dockerfile                                                           0.0s
 => => transferring dockerfile: 346B                                                                           0.0s
 => [internal] load .dockerignore                                                                              0.0s
 => => transferring context: 2B                                                                                0.0s
 => [internal] load metadata for docker.io/library/openjdk:8                                                   2.1s
 => CACHED [1/7] FROM docker.io/library/openjdk:8@sha256:86e863cc57215cfb181bd319736d0baf625fe8f150577f9eb58b  0.0s
 => [2/7] RUN git clone https://github.com/iac-source/inbuilder.git                                            2.2s
 => [3/7] WORKDIR inbuilder                                                                                    0.0s
 => [4/7] RUN chmod 700 mvnw                                                                                   0.7s
 => [5/7] RUN ./mvnw clean package                                                                            10.7s
 => => # Downloading from central: https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter-api/5.5.2/j
 => => # unit-jupiter-api-5.5.2.pom
 => => # Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter-api/5.5.2/ju
 => => # nit-jupiter-api-5.5.2.pom (2.4 kB at 148 kB/s)
 => => # Downloading from central: https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.1.0/apigu
 => => # ardian-api-1.1.0.pom
[root@localhost 4.3.3]# docker run -d -p 30010:80 --name build-img --restart always build
37aff9d89829da2acfc6998b969a708ba91165f6abca885f598c0785f53fa495
[root@localhost 4.3.3]# docker ps
CONTAINER ID   IMAGE              COMMAND                   CREATED          STATUS          PORTS                                                NAMES
37aff9d89829   build              "java -jar app-in-im…"   3 seconds ago    Up 2 seconds    60433/tcp, 0.0.0.0:30010->80/tcp, :::30010->80/tcp   build-img

최적화 후 컨테이너 빌드.

멀티스테이지 핵심 : 빌드위치와 최종이미지 "분리"

 

[root@m-k8s ~]# cd 4.3.4
[root@m-k8s 4.3.4]# ls
Dockerfile  k8s-SingleMaster-18.9_9_w_auto-compl
[root@m-k8s 4.3.4]#
[root@m-k8s 4.3.4]# vi Dockerfile
FROM openjdk:8 AS int-build
LABEL description="Java Application builder"
RUN git clone https://github.com/iac-source/inbuilder.git
WORKDIR inbuilder
RUN chmod 700 mvnw
RUN ./mvnw clean package

FROM gcr.io/distroless/java:8
LABEL description="Echo IP Java Application"
EXPOSE 60434
COPY --from=int-build inbuilder/target/app-in-host.jar /opt/app-in-image.jar
WORKDIR /opt
ENTRYPOINT [ "java", "-jar", "app-in-image.jar" ]
[root@m-k8s 4.3.4]# dnf -y install git
Extra Packages for Enterprise Linux 8 - x86_64                                       14 kB/s | 4.6 kB     00:00
Extra Packages for Enterprise Linux 8 - x86_64                                      3.7 MB/s |  14 MB     00:03
Last metadata expiration check: 0:00:14 ago on Fri 19 May 2023 07:44:38 AM UTC.
Dependencies resolved.
====================================================================================================================
 Package                        Architecture         Version                          Repository               Size
====================================================================================================================
Installing:
 git                            x86_64               2.31.1-3.el8_7                   appstream               160 k
Installed:
  emacs-filesystem-1:26.1-7.el8_7.1.noarch    git-2.31.1-3.el8_7.x86_64            git-core-2.31.1-3.el8_7.x86_64
  git-core-doc-2.31.1-3.el8_7.noarch          perl-Error-1:0.17025-2.el8.noarch    perl-Git-2.31.1-3.el8_7.noarch

Complete!
[root@m-k8s 4.3.4]#
[root@m-k8s 4.3.4]# docker build -t multi-img .
[+] Building 2.0s (13/13) FINISHED
 => [internal] load build definition from Dockerfile                                                           0.1s
 => => transferring dockerfile: 520B                                                                           0.0s
 => [internal] load .dockerignore                                                                              0.1s
 => => transferring context: 2B                                                                                0.0s
 => [internal] load metadata for gcr.io/distroless/java:8                                                      0.7s
 => [internal] load metadata for docker.io/library/openjdk:8                                                   1.5s
 => [int-build 1/5] FROM docker.io/library/openjdk:8@sha256:86e863cc57215cfb181bd319736d0baf625fe8f150577f9eb  0.0s
 => CACHED [stage-1 1/3] FROM gcr.io/distroless/java:8@sha256:34c3598d83f0dba27820323044ebe79e63ad4f137b40567  0.0s
 => CACHED [int-build 2/5] RUN git clone https://github.com/iac-source/inbuilder.git                           0.0s
 => CACHED [int-build 3/5] WORKDIR inbuilder                                                                   0.0s
 => CACHED [int-build 4/5] RUN chmod 700 mvnw                                                                  0.0s
 => CACHED [int-build 5/5] RUN ./mvnw clean package                                                            0.0s
 => [stage-1 2/3] COPY --from=int-build inbuilder/target/app-in-host.jar /opt/app-in-image.jar                 0.1s
 => [stage-1 3/3] WORKDIR /opt                                                                                 0.0s
 => exporting to image                                                                                         0.2s
 => => exporting layers                                                                                        0.1s
 => => writing image sha256:6947ddf7c896d762d7b7ec2c1ae3e1ce9001ed0f30921b6c602c56295dc849eb                   0.0s
 => => naming to docker.io/library/multi-img                                                                   0.0s
[root@m-k8s 4.3.4]#
[root@m-k8s 4.3.4]# docker images
REPOSITORY      TAG       IMAGE ID       CREATED          SIZE
multi-img       latest    6947ddf7c896   29 seconds ago   148MB
[root@m-k8s 4.3.4]# docker run -d -p 2000:80 --name multi --restart always multi-img
12463c28d7ddc74ad67599e262dd209cfe55962c4775851cd0d0ca44e91c811e
[root@m-k8s 4.3.4]#
[root@m-k8s 4.3.4]# docker ps
CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS         PORTS                                                NAMES
12463c28d7dd   multi-img       "java -jar app-in-im…"   8 seconds ago   Up 7 seconds   60434/tcp, 0.0.0.0:2000->80/tcp, :::2000->80/tcp     multi

[root@m-k8s 4.3.4]# curl localhost:2000
src: 172.17.0.1 / dest: localhost

 

+ Recent posts