인프라

Docker에서 rhel8.8 설치하기/rhel8.8 Container에 chrome headless 설치하기

Ramda 2025. 2. 18. 14:02

Overview

  • rhel 환경에서 Chrome을 활용한 PDF 변환이 필요한 상황이 생겼다. 그에 대한 테스트로 도커 컨테이너 내부에 rhel을 설치하고, rhel 환경에서 chrome headless를 설치해보도록 하자, 그 다음 pdf 변환 테스트를 진행해보자

Doker에 rhel8.8 설치하기

  • 도커를 사용하여 rhel 8.8환경의 컨테이너 설치를 먼저 해보자 Red Hat Container Catalog에서 사용 가능한 rhel 8.8의 이미지를 찾아본다.
  • image를 찾아보면 최소화된 버전만 존재하는데, 이유는 컨테이너는 경량화를 목표로 사용하기 때문에 취지에 맞는 경량화 버전만 제공한다고 한다. 그래서 필요한 설정과 명령어들은 직접 설치를 해야한다.
  • (dockerfile을 활용한 표준버전 설치도 가능하지만, 테스트 목적의 rhel에는 필요없다고 생각하여 경량화 버전을 사용한다.)
  • 이미지를 로컬 시스템으로 pull하고, docker를 이용하여 컨테이너를 실행한다.
    docker pull registry.access.redhat.com/ubi8/ubi:8.8
    
    #이미지 이름을 rhel8.8로 설정
    docker tag registry.access.redhat.com/ubi8/ubi:8.8 rhel8.8 
    
    #컨테이너 이름은 --name 설정으로 rhel-container로 설정
    docker run -it --name rhel-container rhel8.8 /bin/bash 
    ​
  • 만약 “This system is not registered with an entitlement server. You can use subscription-manager to register.” 같은 에러가 뜬다면 먼저 redhat에서 회원가입을 통해 라이센스를 다운 받아야한다.
    # 로그인
    subscription-manager register
    
    # id와 password 입력하고 라이센스 사용
    ​
  • 경량화된 버전이기에 관련 패키지들을 다운로드 한다.
    # 기본 yum package update
    yum update
    
    # clear와 같은 기본기능 다운
    yum install -y ncurses
    ​

 

rhel 8.8에 headless chrome 설치하기

  • rhel에 headless chrome을 설치하기 전에 최소화된 버전의 redhat을 다운 받았기 때문에 설치에 필요한 도구와 라이브러리를 설치하고 설치를 진행한다.
    # 필요한 패키지 설치, wegt : web server에서 파일을 다운로드하는 명령어
    yum install -y wget 
    # headless chrome을 설치, rpm 파일 이름을 chrome.rpm으로 변경
    wget <https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm> -O chrome.rpm
    
    # chrome.rpm에 필요한 패키지와 의존성 다운로드하는 명령어(여기선 chrome.rpm으로 이름을 설정하였다.)
    yumdownloader --resolve chrome.rpm
    
    # 만약 yumdownloader명령어가 없다면 다운로드해야한다
    yum install yum-utils
    ​
  • 설치가 완료되었다면, 다운로드한 rpm 파일을 설치하고 테스트 해본다.
    yum install -y ./chrome.rpm
    
    # 테스트 진행 명령어(html 파일이 동작 한다면, 설치 완료)
    google-chrome --no-sandbox --headless --disable-gpu --dump-dom <https://www.example.com>
    
    # 설치 후 PDF print 시 명령어
    google-chrome --no-sandbox --headless --disable-gpu --print-to-pdf=/path/to/example.pdf <https://www.example.com>
    # pdf 실행해보기
    evince /path/to/output.pdf
    ​
  • 정상적으로 pdf가 나타난다면 완료된 것 이다.

 

Reference

 

https://catalog.redhat.com/software/containers/explore

About Red Hat Ecosystem Catalog The Red Hat Ecosystem Catalog is the official source for discovering and learning more about the Red Hat Ecosystem of both Red Hat and certified third-party products and services. We’re the world’s leading provider of en

catalog.redhat.com

 

 

Google Chrome installation RHEL 8 - Red Hat Customer Portal

Access Red Hat’s knowledge, guidance, and support through your subscription.

access.redhat.com

 

 

additional options in Chrome headless print-to-pdf

I need help one more time. I am trying to print a page to pdf using headless feature of the chrome. However, header and footer is present in the pdf. I found that this option as been implemented in

stackoverflow.com

 

'인프라' 카테고리의 다른 글

RHEL 디렉토리 구조  (0) 2025.02.20
rhel 환경에서 PDF 용량 줄이기  (0) 2025.02.18
PM2 살펴보기  (0) 2025.02.18
Offline에서 Docker 설치하기  (0) 2023.02.02
Offline에서 yum.repo local 설정  (4) 2023.02.01