Docker Install - EC2

Docker는 host OS’s kernel을 이용하므로

  • Windows Containers can run on Windows OS
  • Also Linux Containers can run on Linux OS

EC2 instance : Ubuntu 18, t2.micro

설치에 관한 공식 문서 : https://docs.docker.com/

docker 설치

$ sudo apt install docker.io

docker 설치 후 docker service가 실행되고 있는지 본다.

$ systemctl status docker
$ docker images

라고 하면 permission denied라고 나온다.

Only the root user can connect to the docker daemon by CLI.

$ sudo vim /etc/group

을 치면 docker:x:115: 끝에 ubuntu 유저가 없다.

$ whoami

로 현재 user 조회

$ sudo usermod -aG docker ubuntu

이제

$ id ubuntu

라고 치면

uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),108(lxd),114(netdev),115(docker)

docker group에 포함된 것을 볼 수 있다.

log out하고 다시 log in하면 이제 docker images를 볼 수 있다.

Docker test

$ docker run hello-world

docker run 은 create image라는 뜻을 가진다.

위를 실행하면 docker hub에서 hello-world를 찾아서 image를 pull해온다.

All this container does is print some messages.

docker ps하면 안 보이지만

$ docker ps -a

하면 hello-world docker가 보인다.

NAMES에는 정해주지 않으면 임의의 이름이 정해져서 나온다.

DockerHub

hub.docker.com에 가면 official image도 있고, 자신만의 이미지도 업로드할 수 있다.

It is called a registry.

DockerHub : Registry for Docker images

Docker Image

  • It’s a stopped Container like a VM image
  • Consists of multiple layers and own file system format, and all the layers will be in read only mode.
  • An app will be bundled in an image.
  • Containers runs from the images.
    • Vagrant box같은 image는 the VM will be the complete clone of the image, but containers are running from the images directly → you can’t remove image if the container is running.
    • Docker images become containers when they run on a Docker engine.
  • Images are called as Repositories in Registries.
    • e.g. Jenkins repository in the Docker Hub registry

Docker Registries

→ Storage for Docker images.

DockerHub is not the only registry, there are other cloud registries.

  • GCR (Google Container Registry)
  • Amazon ECR → can create your own images and upload

also Inhouse or Local Registries

  • Nexus 3+
  • Jfrog Artifactory
  • DTR(Docker Trusted Registry)

'DevOps와 Infra > Docker' 카테고리의 다른 글

Docker Run  (0) 2023.08.02
Docker 기본  (0) 2023.07.27
Docker Image -> Nexus Push  (0) 2023.04.13
Docker 정리  (0) 2023.02.07
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유