DEV/Docker-Redhat

1. Rocky Linux 8 Docker 설치

서버엔지니어 2023. 2. 27.
728x90

## firewalld 방화벽 끄기

systemctl disable firewalld && systemctl stop firewalld

 

## selinux disabled하기
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
localectl set-locale LANG=ko_KR.utf8

 

## 저장소 추가
dnf install -y epel-release
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf install -y rocky-release

##Rocky repo 활성화
sed s/enabled=0/enabled=1/g -i /etc/yum.repos.d/Rocky-Extras.repo
sed s/enabled=0/enabled=1/g -i /etc/yum.repos.d/Rocky-HighAvailability.repo
sed s/enabled=0/enabled=1/g -i /etc/yum.repos.d/Rocky-NFV.repo
sed s/enabled=0/enabled=1/g -i /etc/yum.repos.d/Rocky-Plus.repo
sed s/enabled=0/enabled=1/g -i /etc/yum.repos.d/Rocky-PowerTools.repo
sed s/enabled=0/enabled=1/g -i /etc/yum.repos.d/Rocky-RT.repo
sed s/enabled=0/enabled=1/g -i /etc/yum.repos.d/Rocky-ResilientStorage.repo

 

## default 환경 변수

echo " " >> /etc/profile
echo "####default PATH#####" >> /etc/profile
echo "export PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin" >> /etc/profile
echo "#####################" >> /etc/profile

 

## 기본 개발환경 설치

dnf install -y libdb-devel libxslt libxslt-devel net-snmp-devel readline-devel readline unixODBC unixODBC-devel libicu-devel icu libicu libc-client libc-client-devel libc-client-2007f freetype-devel freetype libXpm libXpm-devel libpng-devel libvpx libcurl libcurl-devel libzip environment-modules uw-imap-utils uw-imap-devel uw-imap uw-imap-static pam-devel libldb-devel bzip2-devel bzip2 bzip2-libs ncurses-libs ncurses-devel ncurses mysql-devel libjpeg-devel openssl openssl-devel openssl-libs libxml2 libxml2-devel libmcrypt libmcrypt-devel mhash mhash-devel libmhash libmhash-devel expat-devel expat gmp gmp-devel krb5-devel wget make cmake gdbm gdbm-devel libtiff libtiff-devel flex zlib-devel zlib gd gd-devel patch t1lib t1lib-devel libtidy libtidy-devel gcc gcc-c++ libtermcap-devel dialog sqlite-devel oniguruma mod_ssl postgresql-devel lcov systemtap-sdt-devel elfutils-devel libwebp-devel libwebp git gzip automake binutils gettext libaio libaio-devel perl redhat-rpm-config rpm-build rpm-sign cyrus-sasl cyrus-sasl-devel curl curl-devel libtirpc-devel libudev-devel libpng* freetype* krb5* libtool* gcc* pcre* gdbm* libtiff* libmcrypt* mhash* curl* zlib* libjpeg* expat* gmp* nghttp2 libnghttp2-devel glibc autoconf libtirpc* rpcgen numactl numactl-devel ncurses-compat-libs libevent-devel liblz4* libzmq* msgpack* gnutls-devel gnutls-utils gnutls* lz4* libxml2* java-1.8.0* zeromq zeromq-devel bison-devel bison bison* jemalloc* boost boost-devel zstd snappy snappy-devel Judy libzstd* libxml* enchant enchant-devel enchant2 enchant2-devel hash* libhash* mingw32-win-iconv mingw32* krb5* openldap* oniguruma* libedit* recode* json-devel mod_session net-snmp* xmlrpc* libzip* aspell-devel ImageMagick ImageMagick-devel libffi libffi-devel vim glibc-langpack-en glibc-langpack-ko zlib* patchelf gperftools-devel libssh-devel doxygen libvpx-devel yum-utils

 

## vi -> vim 으로 변환
echo "" >> /etc/bashrc
echo "alias vi='vim'" >> /etc/bashrc
echo "" >> /etc/bashrc
source /etc/bashrc

## 패키지 업그레이드

dnf update -y
dnf upgrade -y

 

## Docker repository 추가

dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

 

## Docker 설치

dnf install -y docker-ce docker-ce-cli containerd.io

 

## Docker 실행 및 시작프로그램 등록

systemctl restart docker && systemctl enable docker

 

## 설치 테스트

# docker run hello-world

========================================================================

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:6e8b6f026e0b9c419ea0fd02d3905dd0952ad1feea67543f525c73a0a790fefb
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/

========================================================================

 

기본적으로 docker 명령을 실행하려면 루트 권한이 필요합니다. 즉, 명령 앞에 sudo를 붙여야 합니다. Docker 설치 중에 자동으로 생성되는 docker 그룹의 사용자가 실행할 수도 있습니다. sudo 접두사를 지정하지 않거나 docker 그룹에 속하지 않고 docker 명령을 실행하려고 하면 다음과 같은 결과가 표시됩니다.

# root 로 아닌경우

usermod -aG docker $(whoami)

 

# docker 명령어

docker [option] [command] [arguments]

 

# docker --help

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Common Commands:
  run        이미지에서 새 컨테이너 생성 및 실행
  exec       실행 중인 컨테이너에서 명령 실행
  ps          컨테이너 목록보기
  build      도커 파일에서 이미지 빌드
  pull        레지스트리에서 이미지 다운로드
  push      이미지를 레지스트리에 업로드
  images  이지지 보기
  login       레지스트리에 로그인
  logout     레지스트리에서 로그아웃
  search    허브에서 이미지 검색
  version    도커 버전 정보 표시
  info        시스템 전체 정보 표시

Management Commands:
  builder     빌드 관리
  buildx*     Docker Buildx (Docker Inc., v0.10.2)
  compose*    Docker Compose (Docker Inc., v2.16.0)
  container  컨테이너 관리
  context     컨텐츠 관리
  image      이미지 관리
  manifest   도커 이미지 매니페스트 및 매니페스트 목록 관리
  network    네트워크 관리
  plugin      플러그인 관리
  scan*      도커 스캔 
  system    도커 관리
  trust        도커 이미지의 신뢰성 관리
  volume    볼륨관리

Swarm Commands:
  swarm       Manage Swarm

Commands:
  attach       실행중인 컨테이너에 로컬 표준 입출력과 에러 스트림 연결 
  commit      컨테이너 변경사항에서 새 이미지 생성
  cp              컨테이너와 로컬 파일 시스템 간에 파일/폴더 복사
  create       새 컨테이너 만들기/생성

  diff            컨테이너 파일 시스템의 파일 또는 디렉터리에 대한 변경 사항 검사
  events       서버에서 실시간 이벤트 가져오기
  export       컨테이너의 파일 시스템을 tar 아카이브로 내보내기
  history       이미지의 히스토리 보기
  import       파일 시스템 이미지를 만들기 위해 tarball에서 내용 가져오기
  inspect      Docker 개체에 대한 낮은 수준의 정보 반환
  kill             실행중인 컨테이너 강제 종료 Kill one or more running containers
  load           tar 아카이브 또는 STDIN에서 이미지 로드
  logs           컨테이너 로그 가져오기
  pause        하나 이상의 컨테이너 내 모든 프로세스 일시 중지
  port           컨테이너에 대한 포트 매핑 또는 특정 매핑 나열
  rename     컨테이너 이름 바꾸기
  restart       하나 이상의 컨테이너 재시작
  rm             하나 이상의 컨테이너 제거
  rmi            하나 이상의 이미지 제거
  save          하나 이상의 영상을 tar 아카이브에 저장(기본적으로 STDOUT로 스트리밍)
  start           하나 이상의 실행 중인 컨테이너 중지
  stats          컨테이너 리소스 사용 통계의 실시간 스트림 표시
  stop           하나 이상의 실행 중인 컨테이너 중지
  tag            SOURCE_IMAGE를 참조하는 TARGET_IMAGE 태그 생성
  top            컨테이너의 실행 중인 프로세스 표시
  unpause    하나 이상의 컨테이너 내 모든 프로세스 일시 중지 취소
  update       하나 이상의 컨테이너 구성 업데이트
  wait            하나 이상의 컨테이너가 멈출 때까지 차단 후, 다음 출구 코드를 출력

Global Options:
      --config string      클라이언트 구성 파일의 위치(기본값 "/root/.docker")
  -c, --context string    데몬에 연결하는 데 사용할 컨텍스트의 이름(DOCKER_HOST envar 및 기본 컨텍스트 집합을 "도커 컨텍스트 사용"으로 재정의함)
  -D, --debug              디버그 모드 사용
  -H, --host list           연결할 데몬 소켓
  -l, --log-level string   로깅 레벨 설정 ("debug", "info", "warn", "error", "fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            버전 정보표시
Run 'docker COMMAND --help' for more information on a command.

For more help on how to use Docker, head to https://docs.docker.com/go/guides/

 

아래 찾기

# docker search rockylinux
NAME                                                DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
rockylinux                                          The official build of Rocky Linux.              113       [OK]
dokken/rockylinux-8                                 A docker container for use with Test Kitchen…   2
dokken/rockylinux-9                                                                                 1
rockylinux/rockylinux                                                                               56
litmusimage/rockylinux                                                                              0
rockylinux/rockylinux-shim                          RockyLinux shim-review images                   0
arm64v8/rockylinux                                  The official build of Rocky Linux.              1
robertdebock/rockylinux                             Container to test Ansible roles in, includin…   0
rockylinux/rocky-toolbox                            Toolbox image for Rocky Linux - https://gith…   1
106061/rockylinux_cicd                              For CI/CD RockyLinux                            0
amd64/rockylinux                                    The official build of Rocky Linux.              0
arpaesimc/rockylinux                                                                                0
romcheck/rockylinux                                                                                 0
mhaluska/rockylinux-php                             Container based on Rocky Linux with Apache2 …   0
gammabytehosting/rockylinux                         Rocky Linux minimal image.                      1
tdsfdw/rockylinux8-postgresql                       Rocky Linux 7 images with PostgreSQL officia…   0
casjaysdevdocker/rockylinux                         Docker build files for rockylinux               0
bordercloud/rockylinux-apache-php-mariadb-rdfunit                                                   0
bordercloud/rockylinux-virtuoso7                                                                    0
buluma/rockylinux                                                                                   0
pats22/rockylinux8-rcli                                                                             0
juliogonzalez/rockylinux8-postgresql                Rocky Linux 8 images with PostgreSQL officia…   0
antlabskr/rockylinux                                Various rockylinux images used for developme…   0
buluma/rockylinux8                                                                                  0
rubyapps/rockylinux-devtools                        Dockerized Rocky Linux with 'Development too…   0

'DEV > Docker-Redhat' 카테고리의 다른 글

0. Docker 명령어 정리  (0) 2023.04.02
2. Rocky Linux 8 APM 설치  (0) 2023.02.28

댓글