[Docker] 도커 시작 & 기본 명령어

Kwon·2023년 12월 20일
0

Docker

목록 보기
1/3
post-thumbnail

Docker

Server Setting

  • 서버 외부 접속을 위해 NCP의 공인, 서버 접속용 공인 IP를 활용
  • 설정하는 법 링크텍스트
  • cmd 창에서 ssh root@'서버 IP' -p '포토번호' 와 자신이 설정한 PW를 입력해 서버 접속

  • 접속 후 다음과 같이 코드 입력

# Uninstall old versions
yum remove docker \
    docker-client \
    docker-client-latest \
    docker-common \
    docker-latest \
    docker-latest-logrotate \
    docker-logrotate \
    docker-engine

# Set up the repository
# Install the yum-utils package (which provides the yum-config-manager utility) and set up the repository.
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# Install Docker engine.
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Start Docker.
systemctl start docker
systemctl enable docker

# Verify that the Docker Engine installation is successful by running the hello-world image.
docker run hello-world

Running status

  • 도커 설치 완료가 되면 systemctl status docker 를 입력해 도커가 잘 돌아가고 있는지 확인

  • 위와 같이 녹색불 뜨면 성공, 빨간색 실패

etc

도커 정지하는 방법
systemctl stop docker

도커 시작
systemctl start docker

도커 재시작
systemctl restart docker

재부팅 시 자동으로 도커 실행
systemctl enable docker

자동에서 수동 변화
systemctl disable docker

컨테이너 삭제
docker rm -f $(docker ps -qa)

이미지 삭제
docker rmi -f $(docker images -qa)

안쓰는 네트워크 삭제
docker network prune -f

안쓰는 볼륨 삭제
docker volume prune -f

도커 프로젝트 삭제
rm -rf /docker_projects

profile
📲 @bu_kwon_2 / 💻 dnu05043.log / ⌨ Back-end / 🦁 LikeLion

0개의 댓글

관련 채용 정보