본문 바로가기

Java/Deploy

[Docker] Mac에서 도커 시작하기, Docker Tutorial

반응형

 

도커 커뮤니티 사이트(hub.docker.com)에 접속해 회원가입 후 첫 화면에서 보이는 "Get started Started with Docker Desktop"을 통해 Docker.dmg 파일을 통해 설치하면 된다.

 

Docker Hub

Docker Certified:Trusted & Supported Products Certified Containers provide ISV apps available as containers. Certified Plugins for networking and volumes in containers. Certified Infrastructure delivers an optimized and validated Docker platform for enterp

hub.docker.com

 

설치가 정상적으로 되었으면, '터미널'에서 설치된 버전이 무엇인지 확인이 가능하다.

 

% docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:21:11 2020
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

 

요즈음의 도커는 GUI를 제공하는 Application를 통해 하고 있으나, 사실은 명령행을 통해 docker를 조작한다.

다음 Step을 따라가면 도커를 설치한 후 테스트(build, run)해볼 수 있는 것 같다.

Step 1.

First, clone a repository

The Getting Started project is a simple GitHub repository which contains everything you need to build an image and run it as a container.

Install Git if you don’t have it already.

 

git clone https://github.com/docker/doodle.git

 

Step 2.

Now let's build and tag a Docker image.

A Docker image is a private filesystem, just for your container. It provides all the files and code your container will need. Running the docker build command creates a Docker image using the Dockerfile. This built image is in your machine's local Docker image registry.

 

cd /docker-tutorial &&
docker image build -t [회원ID]/docker-tutorial .

 

Step 3.

Great! Now let's run your first container.

Running a container launches your software with private resources, securely isolated from the rest of your machine.

 

docker container run -it --rm [회원ID]/docker-tutorial

 

또한, 다음의 명령어를 통해 도커의 이미지를 포트 포워딩을 하여야 로컬 환경에서 확인이 가능하다.

 

docker container run -d -p 80:80 [회원ID]/docker-tutorial

 

You'll notice a few flags being used. Here's some more info on them:

  • -d → run the container in detached mode (in the background)
  • -p 80:80 → map port 80 of the host to port 80 in the container
  • [회원ID]/cheers2019 → the image to use

정상적으로 포트 포워딩이 진행이 되었다면, 도커 컨테이너에 어떻게 할당되어 있는 지 확인이 가능하다.

 

% docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
37b9a68970d0        docker101tutorial   "/docker-entrypoint.…"   31 minutes ago      Up 31 minutes       0.0.0.0:80->80/tcp   docker-tutorial

 

Step 4.

Share your image on Docker Hub

Once you're ready to share your container with the world, push the image that describes it to Docker Hub.

 

docker login &&
docker push [회원ID]/docker-tutorial
반응형

❥ CHATI Github